DEV Community


Posted on

Why use Flake8 to enforce PEP8

Flake8, as a tool, is a boon for those wanting to maintain clean, tight, and concise Python codebase. You might wonder, "If I want to maintain a clean and readable Python codebase, I might as well just use something like PyLint, what's so good about Flake8?".

Glad that you got curious!

You see, Flake8 is quite handy for catching errors and even though PyLint also helps to some extent with formatting, it can be tough to catch PEP8 errors with PyLint since it does not enforce PEP8.

Hence, if you plan on enforcing PEP8, Flake8 is the way to go.

Overall, reasons you might want to consider using Flake8 include :

  • It has got great support for plugins that PyLint can't even come close to including but not limited to doctoring style and type-checking.

  • Flake8 plugins are easier to write relative to PyLint plugins, in terms of, lines of code.

  • It enforces PEP8 which is, in fact, the whole point!

P.S I recommend using Flake8 with your CI as well. Also, you can always use Flake8 in conjunction with something like PyLint.

Discussion (0)