Skip to content

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:

Language: Shell
(venv) $ python -m pip install flake8

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

Language: 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:

Language: Config File Filename: .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:

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

Select or ignore codes from the command line:

Language: Shell
$ flake8 --select E,F,W --extend-ignore=E203,W503
Python Code Quality Illustration

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.

intermediate best-practices python tools


By Leodanis Pozo Ramos • Updated July 19, 2026
Morty Proxy This is a proxified and sanitized view of the page, visit original site.