pyflakes icon indicating copy to clipboard operation
pyflakes copied to clipboard

handle del inside function definition

Open Hanaasagi opened this issue 6 years ago • 3 comments

It will resolve #428.

a = 1

def test():
    a = 2
    del a
    print(a)

test()

handleNodeLoad will always search the name a from function scope to module scope, even if we defined a same name in function and then delete it. We need to remember the name we deleted. Because of name shadowing, Python will not search the outer scope.

Hanaasagi avatar Sep 04 '19 14:09 Hanaasagi

Know little about PyPy, it's behavior is different from Python :joy:

Hanaasagi avatar Sep 05 '19 14:09 Hanaasagi

looks like new versions of pypy have different offsets, I'll make a PR to fix that -- should be unrelated to your change here 👍

asottile avatar Sep 05 '19 16:09 asottile

Hello, are there any questions about this PR?

Hanaasagi avatar Jul 01 '21 17:07 Hanaasagi