not removing imports when a symbol is redeclared
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 953
- Forks
- 97
- Avg merge
- 2m
- Merged PRs (30d)
- 4
Description
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 https://github.com/yamenk-gribaudo/pymerger/issues/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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the Python example in the report and trace autoflake's unused-import analysis for a module-level symbol that is redeclared locally. Identify the relevant analysis entry point and add coverage for this case. Done means the imported fix_code is reported as unused and removed while the local definition remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100