-
Notifications
You must be signed in to change notification settings - Fork 393
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
refactor: prefix trimming as a node transformer #113
refactor: prefix trimming as a node transformer #113
Conversation
Co-authored-by: Yusuke Oda <yusuke.oda@predicate.jp>
Co-authored-by: Yusuke Oda <yusuke.oda@predicate.jp>
Co-authored-by: Yusuke Oda <yusuke.oda@predicate.jp>
Co-authored-by: Yusuke Oda <yusuke.oda@predicate.jp>
Co-authored-by: Yusuke Oda <yusuke.oda@predicate.jp>
Co-authored-by: Yusuke Oda <yusuke.oda@predicate.jp>
@Eric-Mendes If you finished refactoring, please push the re-request button (the arrow circle) on the right pane. |
""" | ||
self._prefixes = prefixes | ||
|
||
def visit_Call(self, node: ast.Call) -> ast.Call: |
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.
I think visit_Call
is no longer necessary, as you implemented visit_Attribute
instead, which can process every Attribute
node in the tree.
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.
Without it tests fail. Not sure why
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.
Could you provide the example outputs you observed?
while isinstance(node_value, ast.Attribute): | ||
node_value = node_value.value | ||
|
||
# if outermost prefix matches any given prefix, loose |
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.
I think this policy is not safe as the dropped subtree may involve the stuff that the users didn't expect. It would be better to drop only the leftmost prefix, and provide a way to specify longer chains to drop: "foo.bar" (but this may be somewhat beyond the scope of this pull request).
@Eric-Mendes Hi, it looks all failed tests belong to Since this pull request removed the trimming behavior from |
@Eric-Mendes Hi, it looks the test is still failing, and there's some conflicts against main. I'd appreciate it if you could resolve these issues. |
Closes this pull request due to more than 1 week inactivity. |
Overview
Implemented the change proposed in issue #81.
Details
Couldn't figure out a nice way of implementing automatic detection of used libraries and its aliases as discussed in #88, so in this implementation the user needs to pass them in a
set[str]
calledprefixes
.References
#81 #87
Blocked by
NA