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
I took a look at this, it seems like there are a number of issues at play here:
pyscopes.py::_HoldingScopeFinder currently assumes that a single logical line of code (i.e. a python statement) can only belong only to a single variable scope, but list/generator expression and lambdas are expressions that can create their own variable scope, so this assumption is incorrect. It may take quite a bit of internal rewrite of _HoldingScopeFinder and friends to fix this part of the issue.
currently we don't create a variable scope for List/Generator Comprehension, this is in line with Python 2, where Comprehension leaks its loop variables to the surrounding scope, but it's incorrect for Python 3 code (Comprhensions with scope #422)
Probably the quickest way to fix this is to fix that issue 3 first. That should make rope treat comprehension with Python 2 scope semantics (i.e. leaky loop variable), so renames will work most of the time. In Python 3 though, renames will be a bit overzealous if your loop variable shadows a name in the surrounding scope. We can fix the scoping issue later on.
With code:
When renaming either
some_var
from global orsome_var
from list comprehension scope both variables get renamed.The text was updated successfully, but these errors were encountered: