flake8
flake8 is a command-line Python linter that unifies pycodestyle, Pyflakes, and mccabe under one interface and can be extended with third-party plugins.
Installation and Setup
Install from the Python Package Index (PyPI) into a virtual environment:
(venv) $ python -m pip install flake8
You can run it as a module or via the flake8 entry point:
$ python -m flake8 --version
$ flake8 --help
Configuration is discovered in one of these files: .flake8, setup.cfg, or tox.ini. Settings use INI syntax under a [flake8] section. To keep settings in pyproject.toml, use a plugin likes flake8-toml-config.
Minimal example of a configuration file:
.flake8
[flake8]
max-line-length = 88
extend-ignore = E203,W503
per-file-ignores =
tests/*: F401
Key Features
- Combines style checks, error detection, and complexity limits via pycodestyle, Pyflakes, and mccabe in a single tool.
- Allows for rich configuration with rule selection, ignores, and per-file overrides, plus options like
--extend-selectand--extend-ignore. - Provides a plugin system that adds rules, integrations, and formatters, published broadly on PyPI.
- Integrates with Git hooks through the
pre-commitframework for automated checks.
Usage
Run against the current directory or a path:
$ python -m flake8 .
$ flake8 src/ package_name/module_name.py
Select or ignore codes from the command line:
$ flake8 --select E,F,W --extend-ignore=E203,W503
Related Resources
Course
Managing and Measuring Python Code Quality
Master Python code quality tools like linters, formatters, type checkers, and profilers to measure, manage, and improve the code you write.
By Leodanis Pozo Ramos • Updated July 19, 2026