Skip to content
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

not removing imports when a symbol is redeclared #321

Open
gentunian opened this issue Feb 24, 2025 · 0 comments
Open

not removing imports when a symbol is redeclared #321

gentunian opened this issue Feb 24, 2025 · 0 comments

Comments

@gentunian
Copy link

Consider the following example:

from autoflake import fix_code

def fix_code():
    return "this"

print(fix_code())

import from autoflake import fix_code won't be removed. I found this issue while using pymerger and merging multiple files into a single one. For some reason, pymerger is failing in not including imports that should actually not be included, and instead they are included in the file single file (see yamenk-gribaudo/pymerger#2).

So, if you run autoflake on the file to remove unused imports on symbol redefinition, as shown in the snippet above, it won't succeed in remove those imports.

In the example above fix_code from autoflake is not used in the file. What's being used is fix_code defined in the file instead by inner scoping.

@gentunian gentunian changed the title not removing imports when a symbol is redeclared or has the same name not removing imports when a symbol is redeclared Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant