Community of Python flake8 plugin
Project description
Community of Python Flake8 Plugin
A Flake8 plugin that enforces the Community of Python's custom code style rules. This plugin provides a set of checks designed to promote consistent and idiomatic Python code within the community.
Features
This plugin implements the following code style checks:
- COP001: Use module import when importing more than two names
- COP002: Import standard library modules as whole modules
- COP003: Avoid explicit scalar type annotations
- COP004: Attribute name must be at least 8 characters
- COP005: Variable name must be at least 8 characters
- COP006: Argument name must be at least 8 characters
- COP007: Function name must be at least 8 characters
- COP008: Class name must be at least 8 characters
- COP009: Function identifier must be a verb
- COP010: Avoid
get_prefix in async function names - COP011: Avoid temporary variables used only once
- COP012: Classes should be marked
typing.final - COP013: Wrap module dictionaries with
types.MappingProxyType - COP014: Use dataclasses with
kw_only=True,slots=True,frozen=True - COP015: For-loop variables must be prefixed with
one_ - COP016: Add
*or/when defining more than two regular arguments - COP017: Avoid reassigning variables not annotated with
Mutable
COP017: immutable variables by default
Variables are treated as immutable: reassigning a name with = in the same scope is a violation. When reassignment is intended, allow it explicitly with the Mutable annotation on the first binding:
from cop_extensions import Mutable
counter_value: Mutable[int] = 0
counter_value = compute_next(counter_value) # OK
total_value = 0
total_value = compute_next(total_value) # COP017
The cop_extensions package ships with the plugin distribution and has no runtime dependencies, so importing Mutable in production code does not pull in flake8. Mutable is matched by name, so any import source works (e.g. an in-house typing_extensions.Mutable). Augmented assignments (+=), for-loop variables, attribute and subscript targets, and names declared global/nonlocal are not checked.
Installation
Install the plugin using uv (recommended). For linting, use the flake8 extra:
uv add --dev "community-of-python-flake8-plugin[flake8]"
Or install via pip:
pip install "community-of-python-flake8-plugin[flake8]"
To use the cop_extensions.Mutable marker in production code, add the package without the extra — it has no runtime dependencies:
uv add community-of-python-flake8-plugin
Usage
Run Flake8 with the plugin enabled:
uv run flake8 --select COP --exclude .venv .
Or if installed globally:
flake8 --select COP --exclude .venv .
Configuration
Add the following to your pyproject.toml when using https://pypi.org/project/Flake8-pyproject/:
[tool.flake8]
select = ["COP"]
exclude = [".venv"]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file community_of_python_flake8_plugin-0.6.0.tar.gz.
File metadata
- Download URL: community_of_python_flake8_plugin-0.6.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc54dd9de264d1a222baedfefa47afee8f42adba30ffebfb3632461bdbde1eb6
|
|
| MD5 |
ddb051816a665ba56a2d18adfb3c16b9
|
|
| BLAKE2b-256 |
2cd4bf4fbef3a31290ba99d93a2b94b2bdc98a91ebf5130e2c559802ab612710
|
File details
Details for the file community_of_python_flake8_plugin-0.6.0-py3-none-any.whl.
File metadata
- Download URL: community_of_python_flake8_plugin-0.6.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4233a743185403ea6e6c8fad22b343669a7fac7a4f10d4fe5f69f61720b0f24
|
|
| MD5 |
544622fbb8c4e92ec613a5db926051ec
|
|
| BLAKE2b-256 |
65621632efc7ef65deb866469b886ef3dd3b4c269c04975654d3b44705f24180
|