-
Notifications
You must be signed in to change notification settings - Fork 0
[refactor] Separate transformation to object from ast parsing #161
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,28 +24,57 @@ def get_scope(func: FunctionType) -> ScopeProxy: | |||||||||
| return ScopeProxy(inspect.getmodule(func).__dict__ | vars(builtins)) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def resolve_attribute_to_object(attribute: str, scope: ScopeProxy | object) -> object: | ||||||||||
| """ | ||||||||||
| Resolve a dot-separated attribute string to the actual object it references in the | ||||||||||
| given scope. For example, if attribute is "os.path.join", this function will | ||||||||||
| return the actual join function from the os.path module. | ||||||||||
|
|
||||||||||
| Args: | ||||||||||
| attribute: A dot-separated string representing the attribute to resolve. | ||||||||||
| scope: The scope in which to resolve the attribute. This can be a ScopeProxy | ||||||||||
| or any object that supports attribute access. | ||||||||||
|
|
||||||||||
| Returns: | ||||||||||
| The object that the attribute resolves to in the given scope. | ||||||||||
| """ | ||||||||||
| obj = None | ||||||||||
| try: | ||||||||||
| for attr in attribute.split("."): | ||||||||||
| obj = getattr(obj or scope, attr) | ||||||||||
| return obj | ||||||||||
| except AttributeError as e: | ||||||||||
| raise ValueError(f"Could not find attribute '{attr}' of {attribute}") from e | ||||||||||
|
||||||||||
| raise ValueError(f"Could not find attribute '{attr}' of {attribute}") from e | |
| raise ValueError(f"Could not resolve attribute chain '{attribute}'") from e |
Copilot
AI
Feb 25, 2026
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.
The new 'resolve_attribute_to_object' function lacks test coverage. While existing tests for 'resolve_symbol_to_object' indirectly exercise this function, there are no direct tests verifying its behavior with string inputs like "math.cos". Consider adding tests for this new public function to ensure it works correctly when called directly, which is the purpose mentioned in the PR description.
| raise ValueError(f"Could not find attribute '{attr}' of {attribute}") from e | |
| raise ValueError(f"Could not resolve attribute chain '{attribute}'") from e |
Uh oh!
There was an error while loading. Please reload this page.