Flake8 is a
linter for Python source code. Out of the box, it
will (mostly) enforce the style guidelines defined in
PEP 8, but its real power comes from its rich list of
plugins. Below is a list of plugins I use when developing
flake8-commasmakes sure that all of your lists, dictionaries, function calls, etc. have trailing commas where appropriate. Using this plugin puts an end to noisy diffs and pesky merge conflicts.
flake8-comprehensionsis one of my favorites lately. It prevents redundant function calls and prefers
tupleliterals over function calls when possible. Fixes for its warnings nearly always involve deleting code, and the results are more readable and idiomatic.
flake8-per-file-ignoresallows developers to more granularly configure suppressed
Flake8warnings. This is especially useful in cases such as autogenerated database migrations (via Django or Alembic) and allowing unused imports inside of
I’m sure I’m missing plenty of plugins from this list, and I’m constantly tweaking my configuration. I’m also working on replacing linters with automatic formatters such as yapf and isort where possible. From time to time, I’ll update this post with any noteworthy additions.