Skip to content

Recognize slice and frozendict generics - #28477

Merged
ntBre merged 2 commits into
mainfrom
brent/f401-slice-frozendict
Sep 9, 2026
Merged

ntBre merged 2 commits into
mainfrom
brent/f401-slice-frozendict

Conversation

@ntBre

@ntBre ntBre commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR updates our standard library generic recognition to include frozendict and slice. F401
is just an example of an affected rule because we visit the subscript arguments of known stdlib
generics as type expressions:

// Ex) Optional[int]
Some(typing::SubscriptKind::Generic) => {
self.visit_type_definition(slice);
self.visit_expr_context(ctx);
}

Test Plan

mdtests including F401 to exercise the new behavior

Summary
--

This PR updates our standard library generic recognition to include `frozendict` and `slice`. `F401`
is just an example of an affected rule because we visit the subscript arguments of known stdlib
generics as type expressions:

https://github.com/astral-sh/ruff/blob/275e6112e4c5d383179efaa424c8d774acf9fe58/crates/ruff_linter/src/checkers/ast/mod.rs#L2177-L2181

Test Plan
--

mdtests including `F401` to exercise the new behavior
@ntBre ntBre added rule Implementing or modifying a lint rule python315 labels Sep 9, 2026
@ntBre ntBre mentioned this pull request Sep 9, 2026
30 tasks
Comment thread crates/ruff_linter/resources/mdtest/pyflakes/unused-import.md Outdated
@astral-sh-bot

astral-sh-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@astral-sh-bot

astral-sh-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@ntBre
ntBre marked this pull request as ready for review September 9, 2026 22:00
@ntBre
ntBre enabled auto-merge (squash) September 9, 2026 22:01
@ntBre
ntBre merged commit a02a6b8 into main Sep 9, 2026
56 checks passed
@ntBre
ntBre deleted the brent/f401-slice-frozendict branch September 9, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python315 rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants