Skip to content
Latchkey

flake8: Style Linting Command Reference

The long-standing pyflakes + pycodestyle linter.

flake8 combines pyflakes and pycodestyle to catch unused imports, undefined names, and style violations. It remains a common CI lint gate, though ruff is a faster alternative.

Common flags / usage

  • flake8 . -- lint the current tree
  • --select CODES -- enable only specific checks
  • --extend-ignore CODES -- ignore additional checks
  • --max-line-length N -- set the line-length limit
  • config via setup.cfg, tox.ini, or .flake8

Example

shell
- run: pip install flake8
- run: flake8 --max-line-length=100 src/ tests/

In CI

Keep flake8 settings in setup.cfg or .flake8 so local and CI runs agree. flake8 exits non-zero on any finding, gating the build. Many teams now run ruff check for the same coverage at much higher speed.

Key takeaways

  • flake8 catches style issues and simple errors via pyflakes/pycodestyle.
  • Configure it in setup.cfg/.flake8 so CI and local match.
  • It gates on any finding; ruff is a faster modern alternative.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →