[code-quality] Possible spurious Flake8 warning F823
Dan Wandschneider
daniel.wandschneider at schrodinger.com
Thu Apr 2 23:04:14 CEST 2015
All-
It seems like when I have a function that does "del" on a global variable,
flake complains that a local variable is referenced before assignment. As
far as I know, the following is valid code:
server = None
def stopServer():
global server
if server:
del server
server = None
test.py:6:8: F823 local variable 'server' (defined in enclosing scope on
line 1) referenced before assignment
I'm using flake --version: 2.1.0 (pep8: 1.4.6, mccabe: 0.2.1, pyflakes:
0.7.3)
I understand that the "del" statement is redundant, but I don't think that
it is wrong, per se. Is this code actually incorrect? If not, is there a
way to suppress this error message? I'm interested in figuring this out as
part of an effort to convince a coworker to start using flake on his/her
code.
Thanks -
Dan W.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/code-quality/attachments/20150402/c94c7e11/attachment.html>
More information about the code-quality
mailing list