Merged
Conversation
Summary -- The existing diagnostic message for `RUF012` suggests annotating the attribute with `typing.ClassVar`, even though the usual fix is actually initializing the field in `__init__`. This PR shortens the main message and moves both of these suggestions into the fix title, which is still displayed despite the rule having no fix. I also considered making the message more similar to `B006`: > Do not use mutable data structures for argument defaults but I kind of preferred my phrasing here. Test Plan -- Updated existing snapshots
sharkdp
approved these changes
Feb 10, 2026
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| RUF012 | 6448 | 3224 | 3224 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+3224 -3224 violations, +0 -0 fixes in 6 projects; 50 projects unchanged)
apache/airflow (+615 -615 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL
- airflow-core/docs/empty_plugin/empty_plugin.py:56:24: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + airflow-core/docs/empty_plugin/empty_plugin.py:56:24: RUF012 Mutable default value for class attribute - airflow-core/docs/empty_plugin/empty_plugin.py:57:24: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + airflow-core/docs/empty_plugin/empty_plugin.py:57:24: RUF012 Mutable default value for class attribute - airflow-core/src/airflow/api_fastapi/common/exceptions.py:59:72: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + airflow-core/src/airflow/api_fastapi/common/exceptions.py:59:72: RUF012 Mutable default value for class attribute - airflow-core/src/airflow/api_fastapi/core_api/datamodels/backfills.py:36:26: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + airflow-core/src/airflow/api_fastapi/core_api/datamodels/backfills.py:36:26: RUF012 Mutable default value for class attribute - airflow-core/src/airflow/configuration.py:277:68: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + airflow-core/src/airflow/configuration.py:277:68: RUF012 Mutable default value for class attribute ... 1220 additional changes omitted for project
apache/superset (+511 -511 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL
- docker/pythonpath_dev/superset_config.py:94:21: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + docker/pythonpath_dev/superset_config.py:94:21: RUF012 Mutable default value for class attribute - superset/advanced_data_type/api.py:46:33: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + superset/advanced_data_type/api.py:46:33: RUF012 Mutable default value for class attribute - superset/annotation_layers/annotations/api.py:100:21: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + superset/annotation_layers/annotations/api.py:100:21: RUF012 Mutable default value for class attribute - superset/annotation_layers/annotations/api.py:110:22: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + superset/annotation_layers/annotations/api.py:110:22: RUF012 Mutable default value for class attribute - superset/annotation_layers/annotations/api.py:112:33: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + superset/annotation_layers/annotations/api.py:112:33: RUF012 Mutable default value for class attribute ... 1012 additional changes omitted for project
binary-husky/gpt_academic (+28 -28 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --no-fix --output-format concise --preview
- crazy_functions/doc_fns/read_fns/excel_reader.py:36:38: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + crazy_functions/doc_fns/read_fns/excel_reader.py:36:38: RUF012 Mutable default value for class attribute - crazy_functions/doc_fns/read_fns/markitdown/markdown_reader.py:56:38: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + crazy_functions/doc_fns/read_fns/markitdown/markdown_reader.py:56:38: RUF012 Mutable default value for class attribute - crazy_functions/doc_fns/read_fns/unstructured_all/paper_metadata_extractor.py:53:38: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + crazy_functions/doc_fns/read_fns/unstructured_all/paper_metadata_extractor.py:53:38: RUF012 Mutable default value for class attribute - crazy_functions/doc_fns/read_fns/unstructured_all/paper_metadata_extractor.py:60:24: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + crazy_functions/doc_fns/read_fns/unstructured_all/paper_metadata_extractor.py:60:24: RUF012 Mutable default value for class attribute - crazy_functions/doc_fns/read_fns/unstructured_all/paper_structure_extractor.py:94:30: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + crazy_functions/doc_fns/read_fns/unstructured_all/paper_structure_extractor.py:94:30: RUF012 Mutable default value for class attribute ... 46 additional changes omitted for project
bokeh/bokeh (+32 -32 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL
- examples/advanced/extensions/font-awesome/fontawesome_icon.py:11:24: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + examples/advanced/extensions/font-awesome/fontawesome_icon.py:11:24: RUF012 Mutable default value for class attribute - examples/advanced/extensions/widget.py:15:22: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + examples/advanced/extensions/widget.py:15:22: RUF012 Mutable default value for class attribute - src/bokeh/application/handlers/code.py:74:21: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + src/bokeh/application/handlers/code.py:74:21: RUF012 Mutable default value for class attribute - src/bokeh/core/property/visual.py:81:22: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + src/bokeh/core/property/visual.py:81:22: RUF012 Mutable default value for class attribute - src/bokeh/document/models.py:68:32: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + src/bokeh/document/models.py:68:32: RUF012 Mutable default value for class attribute ... 54 additional changes omitted for project
latchbio/latch (+1 -1 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --no-fix --output-format concise --preview
- src/latch_cli/centromere/utils.py:73:23: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + src/latch_cli/centromere/utils.py:73:23: RUF012 Mutable default value for class attribute
zulip/zulip (+2037 -2037 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL
- analytics/migrations/0001_initial.py:12:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0001_initial.py:12:18: RUF012 Mutable default value for class attribute - analytics/migrations/0001_initial.py:7:20: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0001_initial.py:7:20: RUF012 Mutable default value for class attribute - analytics/migrations/0001_squashed_0021_alter_fillstate_id.py:35:20: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0001_squashed_0021_alter_fillstate_id.py:35:20: RUF012 Mutable default value for class attribute - analytics/migrations/0001_squashed_0021_alter_fillstate_id.py:41:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0001_squashed_0021_alter_fillstate_id.py:41:18: RUF012 Mutable default value for class attribute - analytics/migrations/0001_squashed_0021_alter_fillstate_id.py:9:16: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0001_squashed_0021_alter_fillstate_id.py:9:16: RUF012 Mutable default value for class attribute - analytics/migrations/0002_remove_huddlecount.py:5:20: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0002_remove_huddlecount.py:5:20: RUF012 Mutable default value for class attribute - analytics/migrations/0002_remove_huddlecount.py:9:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0002_remove_huddlecount.py:9:18: RUF012 Mutable default value for class attribute - analytics/migrations/0003_fillstate.py:5:20: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0003_fillstate.py:5:20: RUF012 Mutable default value for class attribute - analytics/migrations/0003_fillstate.py:9:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0003_fillstate.py:9:18: RUF012 Mutable default value for class attribute - analytics/migrations/0004_add_subgroup.py:5:20: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0004_add_subgroup.py:5:20: RUF012 Mutable default value for class attribute - analytics/migrations/0004_add_subgroup.py:9:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0004_add_subgroup.py:9:18: RUF012 Mutable default value for class attribute - analytics/migrations/0005_alter_field_size.py:5:20: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0005_alter_field_size.py:5:20: RUF012 Mutable default value for class attribute - analytics/migrations/0005_alter_field_size.py:9:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0005_alter_field_size.py:9:18: RUF012 Mutable default value for class attribute - analytics/migrations/0006_add_subgroup_to_unique_constraints.py:5:20: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0006_add_subgroup_to_unique_constraints.py:5:20: RUF012 Mutable default value for class attribute - analytics/migrations/0006_add_subgroup_to_unique_constraints.py:9:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + analytics/migrations/0006_add_subgroup_to_unique_constraints.py:9:18: RUF012 Mutable default value for class attribute - analytics/migrations/0007_remove_interval.py:10:18: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` ... 4043 additional changes omitted for project
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| RUF012 | 6448 | 3224 | 3224 | 0 | 0 |
amyreese
approved these changes
Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The existing diagnostic message for
RUF012suggests annotating the attributewith
typing.ClassVar, even though the usual fix is actually initializing thefield in
__init__. This PR shortens the main message and moves both of thesesuggestions into the fix title, which is still displayed despite the rule having
no fix.
I also considered making the message more similar to
B006:but I kind of preferred my phrasing here.
Test Plan
Updated existing snapshots