You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
def foo(): ...
def bar():
foos = ...
for foo in foos: ...
and then you do slicker oldfile.foo newfile.py to move foo to newfile.py. The result is this:
def bar():
foos = ...
for newfile.foo in foos: ...
which obviously is not correct.
The problem is that a variable is shadowing a function name, so while slicker thinks it's renaming a reference to the function it's actually renaming a reference to the variable.
I think that we could actually do a pretty good job with this, without too much trouble. The idea would be to see to find all places the symbol-to-rewrite is used in an assignment context (in this case "for foo in"), and go up the AST to the function that happens in, and don't do any renaming in that function. But I may be missing something that makes this too hacky to be useful in general.
The text was updated successfully, but these errors were encountered:
This is an example of #19, but I'll leave it open since it has a clearer example. I think it's not hard to do, but it requires actually tracking scopes rather than traversing the AST without much context as we do now. It's not hacky: we're just following the same algorithm python does to figure out name shadowing. But I suspect it's a decent bit of work to refactor such that it's possible.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Suppose you have this file:
and then you do
slicker oldfile.foo newfile.py
to movefoo
to newfile.py. The result is this:which obviously is not correct.
The problem is that a variable is shadowing a function name, so while slicker thinks it's renaming a reference to the function it's actually renaming a reference to the variable.
I think that we could actually do a pretty good job with this, without too much trouble. The idea would be to see to find all places the symbol-to-rewrite is used in an assignment context (in this case "for foo in"), and go up the AST to the function that happens in, and don't do any renaming in that function. But I may be missing something that makes this too hacky to be useful in general.
The text was updated successfully, but these errors were encountered: