Skip to content

Adds COP017 — immutable variables by default#5

Open
mrkaaa wants to merge 5 commits into
community-of-python:mainfrom
mrkaaa:feature/immutable-variables
Open

Adds COP017 — immutable variables by default#5
mrkaaa wants to merge 5 commits into
community-of-python:mainfrom
mrkaaa:feature/immutable-variables

Conversation

@mrkaaa

@mrkaaa mrkaaa commented Jul 9, 2026

Copy link
Copy Markdown

As a replacement for auto-typing-final

mrkaaa and others added 2 commits July 9, 2026 11:22
As a replacement for auto-typing-final
Rewrite mapping_proxy helpers with early returns instead of mutable
accumulators (also drops dead Python 3.8 ast.Index handling; the package
requires Python >=3.10) and make COP017 check helper arguments
keyword-only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread src/community_of_python_flake8_plugin/checks/immutable_variable.py Outdated
Comment thread src/community_of_python_flake8_plugin/checks/immutable_variable.py Outdated
mrkaaa and others added 3 commits July 9, 2026 15:03
The COP017 escape hatch is the Mutable annotation again (runtime marker
exported from the package). The package now has no runtime dependencies,
so importing Mutable in production code does not pull in flake8; linting
installs use the [flake8] extra. The violation message includes the
import instruction so code agents can fix it without extra context.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…notations

Convert all check classes to dataclasses (kw_only=True, slots=True,
frozen=True per COP014) with a uniform syntax_tree field, switching
plugin discovery to keyword instantiation. Type COP017 scope helpers by
behavior (Iterable/Sequence instead of list) and replace object with a
TypeVar in the Mutable marker.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The marker now lives in its own top-level package shipped in the same
wheel (uv_build multi-module), so production code imports
cop_extensions.Mutable without referencing the linter package. The
violation message and docs point to the new import path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants