Python linter rules drive me a bit crazy. Don’t get me wrong, linters have their purpose. Some rules, however, seem to throw the baby out with the bathwater.

For example, let’s take the following snippet:


def foo(bar):
    if bar:
        return True
    else:
        return False

Most linters will suggest that the else statement is unnecessary. The code could be simplified to:


def foo(bar):
    if bar:
        return True
    return False

The word “simplified” here is a misnomer.

Readability is the most important part of code quality. We’ve all been conditioned that the else clause is what will happen when the if conditional isn’t matched. We’re looking for it. It’s a visual cue that helps us understand the code. Removing that queue requires us to to think a little harder about what’s happening.

Verbosity is not always a bad thing.