Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Jul 3, 2025

There's two ways of creating frame info instances, thus, decoupling into two different classes.

armenzg added 2 commits July 3, 2025 14:37
There's two ways of creating a frame info, thus, using two different classes to do so.
@armenzg armenzg self-assigned this Jul 3, 2025
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 3, 2025
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():
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removed block is what would make the frame info be determined based on the filename and module.

frame_info_from_module will now only belong to ModuleBasedFrameInfo.

Image

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:
Copy link
Member Author

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:
Copy link
Member Author

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:
Copy link
Member Author

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
Copy link
Member Author

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.

@armenzg armenzg marked this pull request as ready for review July 3, 2025 18:52
@armenzg armenzg requested review from a team as code owners July 3, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant