False positive: F401 'foo' imported but unused; when marking variable as global variable in a function
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 190
- Avg merge
- 8m
- Merged PRs (30d)
- 13
Description
False positive: F401 'foo' imported but unused
a.py:
from b import foo
def test():
global foo
print(foo)
foo = 'bar'
print(foo)
test()
b.py:
foo = 'foo'
Also resolves this PyCharm Error
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 a.py and b.py example from the issue first, focusing on the global declaration and imported foo. Trace the diagnostic that reports F401 and add coverage for this case; done means the example no longer reports foo as unused while ordinary unused imports still do.
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
- 45/100