Simple nested functions without preceeding blank line are not a violation of PEP 8. It is up to the human to decide readability in this case.
pep8-0.6.1 will emit errors in cases where an extra blank line is not required or appropriate.
Example code, pep8_bug.py:
"""Demonstrate bug"""
def safe_accessors(dictionary=False):
"""simplified from complex test code..."""
if dictionary:
_setattr, _getattr, _delattr = setitem, getitem, delitem
def _hasattr(_dict, value):
return value in _dict
else:
_setattr, _getattr, _delattr, _hasattr = (
setattr, getattr, delattr, hasattr
)
return _setattr, _getattr, _delattr, _hasattr
pep8 output:
pep8_bug.py:9:9: E301 expected 1 blank line, found 0
The correct output is to be silent (or at most emit a silence-able warning).
Reference: "PEP 8" / "Code lay-out" / "Blank Lines"
Simple nested functions without preceeding blank line are not a violation of PEP 8. It is up to the human to decide readability in this case.
pep8-0.6.1 will emit errors in cases where an extra blank line is not required or appropriate.
Example code, pep8_bug.py:
pep8 output:
The correct output is to be silent (or at most emit a silence-able warning).
Reference: "PEP 8" / "Code lay-out" / "Blank Lines"