pyflakes icon indicating copy to clipboard operation
pyflakes copied to clipboard

False positive: F401 'foo' imported but unused; when marking variable as global variable in a function

Open Horstage opened this issue 7 years ago • 1 comments

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

Horstage avatar Nov 13 '18 15:11 Horstage

I think it may be fixed after this is merged. because it actually regard the name as global, that is, if you rebind that name, the global one should be rebound too.

seeeturtle avatar Feb 08 '19 16:02 seeeturtle

Issue confirmed under

$ pip freeze | grep flake 
flake8==3.9.2
pyflakes==2.3.1

janosh avatar Oct 14 '21 15:10 janosh