Registry / testing / pycodestyle

pycodestyle

JSON →
library2.14.0pypypi✓ verified 28d ago

pycodestyle is a tool designed to check Python code against a subset of the style conventions outlined in PEP 8. It's a widely adopted package within the Python ecosystem, helping developers maintain consistent and readable code. The current version is 2.14.0, and the project is actively maintained with regular updates.

pip install pycodestyle
INSTALL
IMPORT
SIG · PYCODESTYLE
P
pycodestyle
testingpythonv2.14.0
Install
1.7s avg
Import
54ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.14.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.056s · 17.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.052s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pycodestyle
✓ import pycodestyle
✗ import pep8
The package was renamed from 'pep8' to 'pycodestyle' to avoid confusion and better reflect its purpose as a tool, not the style guide itself.
StyleGuide
✓ from pycodestyle import StyleGuide
Used for programmatic checking of files or directories, often with custom configurations.
Checker
✓ from pycodestyle import Checker
Used for programmatic checking of a single file.

This quickstart demonstrates how to programmatically use `pycodestyle`'s `StyleGuide` class to check a Python file for PEP 8 compliance. It creates a temporary file with some common style violations, runs the checker, and reports the total number of errors found. You can also run `pycodestyle` directly from the command line: `pycodestyle your_file.py`.

import pycodestyle import os def create_example_file(filename): with open(filename, 'w') as f: f.write("import os, sys # E401 multiple imports on one line\n") f.write("\n") f.write("def my_function( ): # E201 whitespace after '('") f.write(" pass\n") example_file = 'example_code.py' create_example_file(example_file) # Programmatic checking using StyleGuide style_checker = pycodestyle.StyleGuide(quiet=True) report = style_checker.check_files([example_file]) if report.total_errors: print(f"Found {report.total_errors} code style errors.") # For detailed output, you might remove quiet=True or configure the report object # For simplicity, this example only prints the total. else: print("No code style errors found.") # Clean up the example file os.remove(example_file)
pycodestyle --version
Debug
Known issues
breakingThe package was renamed from `pep8` to `pycodestyle`. Projects still importing `pep8` will fail when upgrading or installing `pycodestyle`.
fix
Update all `import pep8` statements to `import pycodestyle` or `from pycodestyle import ...`.
affects: <=1.7.1 (pep8) to >=2.0.0 (pycodestyle)
breaking`pycodestyle` dropped support for older Python versions. As of version 2.14.0, it requires Python 3.9 or newer.
fix
Ensure your project is running on Python 3.9 or a newer compatible version. Consider using `pyenv` or virtual environments to manage Python versions.
affects: >=2.9.0 (dropped Python 2.7/3.5); >=2.14.0 (requires >=3.9)
gotchaConfiguration files (`setup.cfg`, `tox.ini`, `pyproject.toml`) now expect a `[pycodestyle]` section for configuration, not `[pep8]`.
fix
Rename `[pep8]` sections in your configuration files to `[pycodestyle]`.
affects: >=2.0.0
gotcha`pycodestyle` only checks for a subset of PEP 8 style conventions (e.g., indentation, whitespace, line length). It deliberately does *not* cover other aspects like naming conventions or docstring conventions. For a more comprehensive linting solution, consider tools like `flake8` (which uses `pycodestyle` internally) with appropriate plugins (e.g., `pep8-naming`, `pydocstyle`).
fix
Integrate `flake8` with relevant plugins for broader code quality checks if naming or docstring conventions are desired. `pip install flake8 pep8-naming pydocstyle`.
affects: All versions
Errors
Common errors & fixes
E501 line too long (X > Y characters)
A line of code exceeds the maximum allowed character length, which defaults to 79 characters according to PEP 8.
fix
Refactor the long line into multiple shorter lines, use implicit string concatenation for long strings, or configure pycodestyle to increase the --max-line-length (e.g., `pycodestyle --max-line-length=120`) or ignore the error with `# noqa: E501` on the line.
W292 no newline at end of file
The Python source file does not end with a single blank line.
fix
Add a blank line at the very end of your `.py` file.
E401 multiple imports on one line
Multiple modules are imported on a single line using a comma-separated list, which violates PEP 8.
fix
Place each import statement on its own separate line.
F401 'module' imported but unused
A module or name has been imported into the file but is not subsequently used within the code. While technically a Pyflakes error, it's commonly reported when using tools like Flake8, which integrates pycodestyle and pyflakes.
fix
Remove the unused import statement. If it's an `__init__.py` file and the import is intended for re-export, add the name to the module's `__all__` variable to explicitly declare it as part of the public API, or use `# noqa: F401` to suppress the warning for that specific line.
Upgrade
Version history
2.14.0latest on PyPI · released Jun 20, 2025
Audit
Dependencies
pythonrequiredRuntime dependency for the checker logic.
Agent activity
12 hits · last 30 days
node
10
Resources
pycodestyle — pip install pycodestyle · libregistry