-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ruff
] Extend FA102 with listed PEP 585-compatible APIs
#20659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
collections.abc
typesruff
] Extend FA102 with collections.abc
types
|
There was a problem hiding this 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.
ruff
] Extend FA102 with collections.abc
typesruff
] Extend FA102 with rest of PEP 585 generics
ruff
] Extend FA102 with rest of PEP 585 genericsruff
] Extend FA102 with rest of PEP 585-compatible APIs
ruff
] Extend FA102 with rest of PEP 585-compatible APIsruff
] Extend FA102 with listed PEP 585-compatible APIs
There was a problem hiding this 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!
* 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)
Resolves #20512
This PR expands FA102’s preview coverage to flag every PEP 585-compatible API that breaks without from
from __future__ import annotations
, includingcollections.abc
. The rule now treats asyncio futures, pathlib-style queues, weakref containers, shelve proxies, and the fullcollections.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.