Open
Description
$ pycodestyle --version
2.7.0
If you have two blank lines, a comment, and then a nested function, E306 is raised erroneously.
(Since this false positive requires a genuine violation of E303, I don't think it's a big deal. But I noticed it, so I'm reporting it.)
The following functions both trigger false postives for E306.
def bad():
_ = None
# arbitrary comment
def inner(): # E306 not expected (but happening! 1/2)
pass
def bad():
_ = None
# arbitrary comment
def inner(): # E306 not expected (but happening! 2/2)
pass
For context, this snippet contains the false positives as well as cases that don't trigger E306:
def bad():
_ = None
# arbitrary comment
def inner(): # E306 not expected (but happening! 1/2)
pass
def bad():
_ = None
# arbitrary comment
def inner(): # E306 not expected (but happening! 2/2)
pass
def good():
_ = None
# arbitrary comment
def inner(): # E306 not expected
pass
def good():
_ = None
# arbitrary comment
def inner(): # E306 not expected
pass
def good():
_ = None
# arbitrary comment
def inner(): # E306 not expected
pass
If you dump that to a file (e.g., bug.py
) and run pycodestyle on it, you'll get E306 inside the two bad()
functions:
$ pycodestyle --select=E306 --show-source bug.py
bug.py:7:5: E306 expected 1 blank line before a nested definition, found 0
def inner(): # E306 not expected (but happening! 1/2)
^
bug.py:16:5: E306 expected 1 blank line before a nested definition, found 0
def inner(): # E306 not expected (but happening! 2/2)
^
Let me know if there's anything I can clarify/provide, thanks!
Metadata
Assignees
Labels
No labels