pycodestyle
Check Python code against PEP 8 style
TLDR
Check Python file
SYNOPSIS
pycodestyle [--ignore codes] [--select codes] [--max-line-length n] [options] files
DESCRIPTION
pycodestyle (formerly pep8) checks Python code against PEP 8 style guidelines. It identifies formatting issues without modifying code.
PEP 8 defines Python's official style: indentation, spacing, naming, and line length conventions. Consistent style improves readability.
Error codes group related issues. E5 codes relate to line length. W503/W504 handle line breaks in expressions. Specific codes can be ignored.
Configuration files (setup.cfg, tox.ini, .pycodestyle) define project-wide settings. These override command-line defaults.
The tool doesn't fix issues automatically. Use autopep8 or black for automatic formatting.
Integration with editors shows issues in real-time. CI pipelines catch style violations before merge.
PARAMETERS
--ignore CODES
Skip error codes.--select CODES
Show only error codes.--max-line-length N
Line length limit (default 79).--show-source
Show source code.--show-pep8
Show PEP8 documentation.--statistics
Show error statistics.--count
Print total errors.--config FILE
Configuration file.--first
Show first error only.-q, --quiet
Quiet mode.--benchmark
Time the run.
CONFIGURATION
setup.cfg
Project configuration file with a `[pycodestyle]` section for setting max-line-length, ignore, and select options.tox.ini
Alternative project configuration file supporting the same `[pycodestyle]` section options.~/.config/pycodestyle
User-level configuration file for default settings applied when no project config is found.
ERROR CODES
E1xx
Indentation errors.E2xx
Whitespace errors.E3xx
Blank line errors.E4xx
Import errors.E5xx
Line length errors.E7xx
Statement errors.W xxx
Warnings.
CAVEATS
Style checking only - no logical errors. Some rules are debatable (W503 vs W504). Strict line length may not suit all projects.
HISTORY
pycodestyle was originally named pep8, created by Johann C. Rocholl around 2006. It was renamed in 2016 per PEP 8's own advice that Guido's naming conventions are guidelines, not rules.
