pep8-naming
pep8-naming is a plugin for flake8 that checks Python code against PEP 8 naming conventions. It is currently at version 0.15.1 and has a regular release cadence, with multiple releases per year addressing Python version compatibility and new checks.
Warnings
- breaking Python version compatibility has changed across major releases. For example, version 0.15.0 dropped support for Python 3.8 and added support for Python 3.13. The current version (0.15.1) requires Python >=3.9.
- breaking The minimum required version of flake8 has increased. As of pep8-naming 0.13.3, flake8 5.0.0 or later is formally required. Using an older flake8 version may lead to installation issues or unexpected behavior.
- gotcha The behavior of the N808 check for type variable names was updated in 0.15.0 to require `CapWords` convention and optional suffixes (`_co` or `_contra`). Version 0.15.1 further refined this to allow type variable names to start with an underscore. This might cause new N808 errors in existing code.
- gotcha The `--ignore-names` option only applies to a specific subset of naming errors (N802, N803, N804, N805, N806, N815, and N816). Other naming conventions, such as N801 for class names, cannot be ignored using this option.
Install
-
pip install pep8-naming
Imports
- pep8-naming (plugin)
pep8-naming is a flake8 plugin and is not typically imported directly into user code.
Quickstart
# 1. Install flake8 and pep8-naming pip install flake8 pep8-naming # 2. Create a Python file (e.g., my_module.py) with a naming violation # For example, a class name that doesn't use CapWords # class myClass: # pass # 3. Run flake8 from your terminal in the directory containing the file # flake8 my_module.py # Example output for 'class myClass:' might include N801: # my_module.py:1:7: N801 class names should use CapWords convention