Skip to content

not removing imports when a symbol is redeclared #321

Description

@gentunian

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions