-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(auto_config): Use factory to create the right instance #94880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There's two ways of creating a frame info, thus, using two different classes to do so.
def __init__(self, frame: Mapping[str, Any], platform: str | None = None) -> None: | ||
if platform: | ||
platform_config = PlatformConfig(platform) | ||
if platform_config.extracts_filename_from_module(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def create_frame_info(frame: Mapping[str, Any], platform: str | None = None) -> FrameInfo: | ||
"""Factory function to create the appropriate FrameInfo instance.""" | ||
frame_info: FrameInfo | None = None | ||
if platform: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we would always pass platform
, however, it's not important to fix.
@@ -69,23 +111,6 @@ def transformations(self, frame_file_path: str) -> str: | |||
|
|||
return frame_file_path | |||
|
|||
def frame_info_from_module(self, frame: Mapping[str, Any]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to ModuleBasedFrameInfo
.
else: | ||
raise MissingModuleOrAbsPath("Investigate why the data is missing.") | ||
|
||
def __repr__(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two have been moved to the base class.
@@ -22,7 +22,7 @@ | |||
UnexpectedPathException, | |||
UnsupportedFrameInfo, | |||
) | |||
from sentry.issues.auto_source_code_config.frame_info import FrameInfo | |||
from sentry.issues.auto_source_code_config.frame_info import create_frame_info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test module only changes from FrameInfo
to create_frame_info
.
There's two ways of creating frame info instances, thus, decoupling into two different classes.