What is the recommended way to break a long if statement? (W504 line break after binary operator)

If we consult the documentation on flake 8 we see: Anti-pattern Note: Despite being in the anti-pattern section, this will soon be considered the best practice. income = (gross_wages + taxable_interest) Best practice Note: Despite being in the best practice section, this will soon be considered an anti-pattern. income = (gross_wages + taxable_interest) So the … Read more

flake8 complains on boolean comparison “==” in filter clause

That’s because SQLAlchemy filters are one of the few places where == False actually makes sense. Everywhere else you should not use it. Add a # noqa comment to the line and be done with it. Or you can use sqlalchemy.sql.expression.false: from sqlalchemy.sql.expression import false TestCase.obsoleted == false() where false() returns the right value for … Read more

Unintentional trailing comma that creates a tuple

pylintalready detects this as a problem (as of version 1.7). For example, here’s my tuple.py: “””Module docstring to satisfy pylint””” def main(): “””The main function””” thing = 1, print(type(thing)) if __name__ == “__main__”: main() $ pylint tuple.py No config file found, using default configuration ************* Module tuple R: 5, 0: Disallow trailing comma tuple (trailing-comma-tuple) … Read more