autopep8
Automatically format Python code to PEP 8 style
TLDR
Format Python file
SYNOPSIS
autopep8 [--in-place] [--aggressive] [options] files
DESCRIPTION
autopep8 automatically formats Python code to conform to PEP 8 style guide. It fixes issues like whitespace, indentation, and line length while preserving code semantics.
The tool integrates with editors and CI pipelines to enforce consistent Python style.
PARAMETERS
-i, --in-place
Modify files in place-d, --diff
Print diff instead of modifying-r, --recursive
Process directories recursively-a, --aggressive
More aggressive fixes (repeatable for more aggression)--select=errors
Fix only specified errors--ignore=errors
Ignore specified errors--max-line-length=n
Maximum line length (default: 79)--range start end
Only fix lines in range--exclude patterns
Exclude file patterns
CONFIGURATION
setup.cfg
Project-level configuration under `[pycodestyle]` section.pyproject.toml
Project-level configuration under `[tool.autopep8]` section.~/.config/pycodestyle
User-level default configuration for pycodestyle rules.
ERROR CODES
Based on PEP 8:
- E: Errors
- W: Warnings
- Examples: E501 (line too long), W291 (trailing whitespace)
CAVEATS
May conflict with other formatters like black. Aggressive mode can change code logic in rare cases. Review changes before committing. Black is now more popular for opinionated formatting.
HISTORY
autopep8 was created by Hideo Hattori to provide automatic PEP 8 compliance, released around 2010.
