A strict, opinionated flake8 plugin that enforces consistent, simple Python code style and flags complex code patterns.
PyCQA/pycodestyle
A single-file Python checker that tests code against the style conventions of PEP 8, using only the standard library.
- Stars
- 5,165
- Forks
- 762
- Open issues
- 105
- Last commit
- 2 days ago
What is it?
pycodestyle checks Python source code against some of the style conventions defined in PEP 8, the official Python style guide. It reports violations such as multiple imports on one line, wrong blank-line counts between functions, excess whitespace, and lines that are too long, each tagged with a code like E401 or E302 and its location in the file.
The project is distributed as one Python file that needs only the standard library, so it can be dropped into a project directly. Output can be formatted for editors to jump to each error, and the tool can show the offending source line along with the relevant PEP 8 text. A statistics mode summarizes how often each error appears across a codebase.
The tool is built on a plugin architecture, which makes it possible to add new checks. It was formerly known as pep8 and was renamed to avoid confusion with the PEP 8 document itself.
Key features
- 01Checks code against many PEP 8 style rules, each reported with a stable error code.
- 02Ships as a single file that depends only on the Python standard library.
- 03Outputs file, line and column for each error so editors can jump to it.
- 04Can display the source line and related PEP 8 guidance for each violation.
- 05Provides a statistics mode that counts errors across a codebase.
- 06Supports plugins for adding custom checks.
Use cases
- Enforcing consistent PEP 8 formatting in a Python project's continuous integration.
- Getting inline style feedback from an editor while writing Python code.
- Auditing a large legacy codebase to see which style violations are most common.
- Running as a lightweight style check without installing heavier dependencies.
Quick start
- 1
Install pycodestyle with pip
pip install pycodestyle - 2
Run it on a Python file to check style
pycodestyle --first optparse.py
Things to know
- The license is not clearly stated in the metadata (NOASSERTION), so check the repository before reuse.
In collections
Topics
FAQ
- What is pycodestyle?
- A single-file Python checker that tests code against the style conventions of PEP 8, using only the standard library. pycodestyle checks Python source code against some of the style conventions defined in PEP 8, the official Python style guide. It reports violations such as multiple imports on one line, wrong blank-line counts between functions, excess whitespace, and lines that are too long, each tagged with a code like E401 or E302 and its location in the file.
- Is pycodestyle free to use? What license does it have?
- pycodestyle is open source under the Other license. Check the license terms before using it in commercial products.
- Is pycodestyle still maintained?
- Actively maintained. The last commit to pycodestyle was on Nov 4, 2026.
- What can I use pycodestyle for?
- Enforcing consistent PEP 8 formatting in a Python project's continuous integration. Getting inline style feedback from an editor while writing Python code. Auditing a large legacy codebase to see which style violations are most common. Running as a lightweight style check without installing heavier dependencies.
- How do I install pycodestyle?
- Install pycodestyle with pip: pip install pycodestyle Run it on a Python file to check style: pycodestyle --first optparse.py
- Where can I get pycodestyle?
- The source code and installation instructions are on GitHub: https://github.com/PyCQA/pycodestyle
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Flake8 plugin that flags likely bugs and questionable design patterns that pyflakes and pycodestyle don't check.
A Python linter that wraps PyFlakes, pycodestyle and McCabe into one command, with support for third-party plugins.
A flake8 and Pylama plugin that checks whether Python imports are grouped and ordered according to a chosen style guide.
A static code analyser for Python that checks for errors, enforces coding standards, and flags code smells without running your code.
A Python tool that computes McCabe cyclomatic complexity for functions and runs as a flake8 plugin to flag overly complex code.