Skip to content

[flake8-bultins] Detect class-scope builtin shadowing in decorators, default args, and attribute initializers (A003)#20178

Merged
ntBre merged 4 commits intoastral-sh:mainfrom
danparizher:fix-20171
Sep 22, 2025
Merged

[flake8-bultins] Detect class-scope builtin shadowing in decorators, default args, and attribute initializers (A003)#20178
ntBre merged 4 commits intoastral-sh:mainfrom
danparizher:fix-20171

Conversation

@danparizher
Copy link
Contributor

Summary

Fix #20171

@github-actions
Copy link
Contributor

github-actions bot commented Aug 31, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+2 -0 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

apache/airflow (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL

+ providers/fab/src/airflow/providers/fab/auth_manager/models/__init__.py:238:22: A003 Python builtin is shadowed by class attribute `id` from line 209
+ providers/fab/src/airflow/providers/fab/auth_manager/models/__init__.py:245:22: A003 Python builtin is shadowed by class attribute `id` from line 209

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
A003 2 2 0 0 0

@danparizher
Copy link
Contributor Author

We can have this PR expanded to cover #20179 too if it makes sense, since they are in the same scope. Let me know!

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks right to me!

Would you mind gating this behind preview? I thought it was a bug fix when I labeled the issue, but it is likely to cause new diagnostics, as the ecosystem check shows, and I'm a bit wary of reintroducing the issues fixed in #9462, when the first_non_type_parent_scope_id check was added.

The structure of the A001 check looks a bit different to me, so let's leave that for a follow-up PR.

@danparizher danparizher requested a review from ntBre September 11, 2025 16:15
@ntBre ntBre added bug Something isn't working rule Implementing or modifying a lint rule preview Related to preview mode features and removed bug Something isn't working labels Sep 19, 2025
Comment on lines 131 to 133
if reference_scope_id == scope_id {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the part that needs to be preview-gated right? The check currently inside of the preview check is the code we had before.

There shouldn't be any stable changes in the ecosystem report. We may also need to add a preview test runner.

@danparizher danparizher requested a review from ntBre September 21, 2025 22:44
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I pushed one commit running the new tests in preview, but the results look good to me.

@ntBre ntBre mentioned this pull request Sep 22, 2025
7 tasks
@ntBre ntBre merged commit 094bf70 into astral-sh:main Sep 22, 2025
36 checks passed
@danparizher danparizher deleted the fix-20171 branch September 22, 2025 22:22
ntBre added a commit that referenced this pull request Jan 30, 2026
ntBre added a commit that referenced this pull request Jan 30, 2026
ntBre added a commit that referenced this pull request Feb 3, 2026
ntBre added a commit that referenced this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A003 misses some attributes referenced within the class scope

2 participants