Skip to content

Conversation

terror
Copy link
Contributor

@terror terror commented Oct 1, 2025

Resolves #20512

This PR expands FA102’s preview coverage to flag every PEP 585-compatible API that breaks without from from __future__ import annotations, including collections.abc. The rule now treats asyncio futures, pathlib-style queues, weakref containers, shelve proxies, and the full collections.abc family as generics once preview mode is enabled.

Stable behavior is unchanged; the broader matching runs behind is_future_required_preview_generics_enabled, letting us vet the new diagnostics before marking them as stable.

I've also added a snapshot test that covers all of the newly supported types.

Check out https://docs.python.org/3/library/stdtypes.html#standard-generic-classes for a list of commonly used PEP 585-compatible APIs.

@terror terror marked this pull request as ready for review October 1, 2025 02:47
@terror terror changed the title Extend FA102 with collections.abc types [ruff] Extend FA102 with collections.abc types Oct 1, 2025
@amyreese amyreese requested a review from ntBre October 2, 2025 00:23
Copy link
Contributor

github-actions bot commented Oct 2, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

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.

Nice! This looks good to me overall. I just had a couple of small nits and one question/suggestion to handle other PEP-585 generics while we're here. But I'm curious to hear your and @amyreese's thoughts on that too.

@ntBre ntBre added rule Implementing or modifying a lint rule preview Related to preview mode features labels Oct 2, 2025
@terror terror changed the title [ruff] Extend FA102 with collections.abc types [ruff] Extend FA102 with rest of PEP 585 generics Oct 2, 2025
@terror terror changed the title [ruff] Extend FA102 with rest of PEP 585 generics [ruff] Extend FA102 with rest of PEP 585-compatible APIs Oct 2, 2025
@terror
Copy link
Contributor Author

terror commented Oct 2, 2025

@ntBre @amyreese I've re-purposed this PR to include listed PEP 585-compatible APIs here. I've added a preview/non-preview test for all of these as well.

@terror terror changed the title [ruff] Extend FA102 with rest of PEP 585-compatible APIs [ruff] Extend FA102 with listed PEP 585-compatible APIs Oct 2, 2025
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.

Very nice, thank you!

@ntBre ntBre merged commit ebfb33c into astral-sh:main Oct 3, 2025
36 checks passed
@terror terror deleted the extend-fa102-collections branch October 3, 2025 16:20
dcreager added a commit that referenced this pull request Oct 3, 2025
* origin/main:
  [`flake8-bugbear`] Include certain guaranteed-mutable expressions: tuples, generators, and assignment expressions (`B006`) (#20024)
  [`flake8-comprehensions`] Clarify fix safety documentation (`C413`) (#20640)
  [ty] improve base conda distinction from child conda (#20675)
  [`ruff`] Extend FA102 with listed PEP 585-compatible APIs (#20659)
  [`ruff`] Handle argfile expansion errors gracefully (#20691)
  [`flynt`] Fix f-string quoting for mixed quote joiners (`FLY002`) (#20662)
  [ty] Fix file root matching for `/`
  [ruff,ty] Enable tracing's `log` feature
  [`flake8-annotations`] Fix return type annotations to handle shadowed builtin symbols (`ANN201`, `ANN202`, `ANN204`, `ANN205`, `ANN206`) (#20612)
  Bump 0.13.3 (#20685)
  Update benchmarking CI for cargo-codspeed v4 (#20686)
  [ty] Support single-starred argument for overload call (#20223)
  [ty] `~T` should never be assignable to `T` (#20606)
  [`pylint`] Clarify fix safety to include left-hand hashability (`PLR6201`) (#20518)
  [ty] No union with `Unknown` for module-global symbols (#20664)
  [`ty`] Reject renaming files to start with slash in Playground (#20666)
  [ty] Enums: allow multiple aliases to point to the same member (#20669)
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.

FA102 is missing collection.abc types
3 participants