Update typing rewrites for typing_extensions 4.12.0+ #380
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adjusts a few import rewrites so that pyupgrade doesn't overly eagerly rewrite some imports where
typing_extensions
has backported some new features or bugfixes from newer Python versions.(Async)Generator
,(Async)ContextManager
-- these have both had recent changes as part of the PEP-696 implementation in CPython.(Async)Generator
now has default values for some type parameters;(Async)ContextManager
now has an optional second type parameter.isinstance()
checks againstSupportsIndex
became much faster in Python 3.12;typing_extensions
backports those changestyping.runtime_checkable
withtyping_extensions.Protocol
; you'll get a nastyAttributeError
at runtime.typing_extensions
also backports some bugfixes forProtocol
from the early py312 patch releases, so I changed these both so that they're only rewritten on py313+.TypedDict
has a few changes in Python 3.13 for the PEP-705 implementation;typing_extensions
backports those.