In this lesson, you will learn:
- what flake8 is
- why use flake8 over pylint
- how to install flake8
- how to use flake8 to catch Python syntax issues
- flake8's main configuration options
- how to install flake8 plugins to check for additional code issues.
What is Flake8?
Flake8 is a Python linting tool that checks your Python codebase for errors, styling issues and complexity. The Flake8 library is built upon 3 tools:
- PyFlakes - checks your Python codebase for errors
- McCabe - checks your Python codebase for complexity
- pycodestyle - checks your Python codebase for styling issues against PEP8.
The thing that makes Flake8 so great is that it has a great range of plugins to enhance and extend what issues and problems it can look for.
Flake8 vs Pylint
Pylint is another Python linting library. Though it is great, from my experience it’s extremely verbose in the issues and things
it deems problematic. Therefore, out of the box Pylint takes time to tune and configure based on your codebase and environment. Not only this but Flake8’s ecosystem of plugins extends it to catch issues that Pylint does not support. Therefore, this course will only cover Flake8.
How to Install Flake8
To install Flake8, run the following:
poetry add -D flake8