Using PyFlakes and the del operator

428 Views Asked by At

When making use of del in a Python function, I'm getting false positives from PyFlakes telling me that the variable is undefined.

def foo(bar):
    # what if it's ham? eww
    if bar == 'ham':
        del bar
        return
    # otherwise yummy!
    print bar

The above function will return the following error:

C:\temp\test.py:7: undefined name 'bar'

Even though the function will work. Does anyone know of a patch to tweak the ast tree parsing to change how it's being handled? If this something others have run into?

1

There are 1 best solutions below

1
On

So what is your question? Deleting parameter names does not make any sense at all, so this is no real issue anyways ...