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:

Shell
(venv) $ python -m pip install flake8

You can run it as a module or via the flake8 entry point:

Shell
$ 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:

Config 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-select and --extend-ignore.
  • Provides a plugin system that adds rules, integrations, and formatters, published broadly on PyPI.
  • Integrates with Git hooks through the pre-commit framework for automated checks.

Usage

Run against the current directory or a path:

Shell
$ python -m flake8 .
$ flake8 src/ package_name/module_name.py

Select or ignore codes from the command line:

Shell
$ flake8 --select E,F,W --extend-ignore=E203,W503

By Leodanis Pozo Ramos • Updated Dec. 12, 2025