lint: Disable a buggy `pep8` rule on line breaks and operators.

I'd much rather see something like

    if (thing_is_permissible(user, thing)
            or (user_possesses_hammer(user)
                and glass_break_requested(thing))):

than

    if (thing_is_permissible(user, thing) or
            (user_possesses_hammer(user) and
                glass_break_requested(thing))):

because the former makes the overall logic much easier to scan.
Similarly for a formula full of arithmetic rather than Boolean
operators.  And the actual PEP 8 agrees (though until 2016 it
unfortunately had the opposite advice.)

The upstream linter still applies the backward rule, so disable that.
This commit is contained in:
Greg Price 2017-10-25 16:33:10 -07:00 committed by Tim Abbott
parent be309bc8b1
commit 4a6e867046
1 changed files with 12 additions and 0 deletions

View File

@ -79,6 +79,18 @@ def check_pep8(files):
# "do not assign a lambda expression, use a def"
# Fixing these would probably reduce readability in most cases.
'E731',
# "line break before binary operator"
# This is a bug in the `pep8`/`pycodestyle` tool -- it's completely backward.
# See https://github.com/PyCQA/pycodestyle/issues/498 .
'W503',
# This number will probably be used for the corrected, inverse version of
# W503 when that's added: https://github.com/PyCQA/pycodestyle/pull/502
# Once that fix lands and we update to a version of pycodestyle that has it,
# we'll want the rule; but we might have to briefly ignore it while we fix
# existing code.
# 'W504',
]
if len(files) == 0: