Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Slicker can't distinguish variable names from function names. #38

@csilvers

Description

@csilvers

Suppose you have this file:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions