[flake8-self] Ignore attribute accesses on instance-like variables (SLF001)#16149
[flake8-self] Ignore attribute accesses on instance-like variables (SLF001)#16149MichaReiser merged 4 commits intoastral-sh:mainfrom
flake8-self] Ignore attribute accesses on instance-like variables (SLF001)#16149Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| SLF001 | 14 | 0 | 14 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+0 -14 violations, +0 -0 fixes in 3 projects; 52 projects unchanged)
apache/airflow (+0 -6 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- airflow/io/path.py:365:17: SLF001 Private member accessed: `_cp_file` - airflow/models/serialized_dag.py:218:36: SLF001 Private member accessed: `_data` - airflow/models/serialized_dag.py:219:47: SLF001 Private member accessed: `_data_compressed` - airflow/models/taskinstance.py:3084:84: SLF001 Private member accessed: `_execute_task` - providers/databricks/src/airflow/providers/databricks/hooks/databricks.py:716:13: SLF001 Private member accessed: `_do_api_call` - task_sdk/src/airflow/sdk/execution_time/supervisor.py:375:9: SLF001 Private member accessed: `_register_pipe_readers`
apache/superset (+0 -3 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- superset/migrations/shared/migrate_viz/base.py:127:9: SLF001 Private member accessed: `_pre_action` - superset/migrations/shared/migrate_viz/base.py:128:9: SLF001 Private member accessed: `_migrate` - superset/migrations/shared/migrate_viz/base.py:129:9: SLF001 Private member accessed: `_post_action`
bokeh/bokeh (+0 -5 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- src/bokeh/model/model.py:105:13: SLF001 Private member accessed: `_id` - src/bokeh/model/model.py:107:13: SLF001 Private member accessed: `_id` - src/bokeh/protocol/message.py:200:9: SLF001 Private member accessed: `_header_json` - src/bokeh/protocol/message.py:201:9: SLF001 Private member accessed: `_metadata_json` - src/bokeh/protocol/message.py:202:9: SLF001 Private member accessed: `_content_json`
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| SLF001 | 14 | 0 | 14 | 0 | 0 |
Formatter (stable)
✅ ecosystem check detected no format changes.
Formatter (preview)
✅ ecosystem check detected no format changes.
686bd0d to
7b1cc72
Compare
|
Ecosystem changes are all as expected. |
ntBre
left a comment
There was a problem hiding this comment.
Thanks! This looks good to me, but I'd like someone more familiar with the TypeChecker API to have a look too. Maybe @AlexWaygood or @MichaReiser?
MichaReiser
left a comment
There was a problem hiding this comment.
I think this overall is an improvement. Will this be a deviation from the upstream rule?
crates/ruff_linter/src/rules/flake8_self/rules/private_member_access.rs
Outdated
Show resolved
Hide resolved
7b1cc72 to
16e6426
Compare
|
@MichaReiser This would be a deviation, yes, but the rule already contains multiple such deviations. The upstream rule exempts |
Summary
Resolves #9022.
SLF001now recognizes the following as instance-like and will not report them:cls()/mcs()super().__new__()SameClass()/SameClass[int]()/Annotated[SameClass[int], ...]()a: SameClass/a: SameClass[int]/a: Annotated[SameClass[int], ...]The new logic prioritizes avoiding false positives over avoiding false negatives. As the issue is labeled as a bug, the changes are not preview-gated.
Test Plan
cargo nextest runandcargo insta test.