flake8
ℹ️
Flake8 has been largely superseded by newer tools like Ruff, which offer significantly faster performance and more features. Consider using Ruff for new projects.
Flake8 is a Python linting tool that enforces style consistency and checks for programming errors. It combines multiple code quality tools into a single interface: PyFlakes for logical errors, pycodestyle for style checking, and mccabe for code complexity checking.
Key Features
Code Analysis
- Detects undefined variables and imports
- Identifies unused imports and variables
- Finds syntax errors and questionable coding patterns
- Measures cyclomatic complexity
Style Enforcement
- Validates PEP 8 compliance
- Checks line length limits
- Enforces whitespace rules
- Verifies import ordering
Configuration Support
- Per-project settings via
setup.cfg
,tox.ini
, or.flake8
- Line-level error suppression with
# noqa
- Granular rule enabling/disabling
- Custom maximum line length
Usage
Basic command line usage:
# Install with uv
uv pip install flake8
# Run flake8
flake8 path/to/code/
Limitations
- No auto-fix capabilities
- Slower performance compared ruff
- Limited type checking support
- No formatting capabilities
Learn More
Last updated on