Skip to content
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

Update typing rewrites for typing_extensions 4.12.0+ #380

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

AlexWaygood
Copy link
Contributor

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 against SupportsIndex became much faster in Python 3.12; typing_extensions backports those changes
  • It no longer works to use typing.runtime_checkable with typing_extensions.Protocol; you'll get a nasty AttributeError at runtime. typing_extensions also backports some bugfixes for Protocol 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.

Copy link
Owner

@asottile asottile left a comment

Choose a reason for hiding this comment

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

@asottile asottile merged commit e2015f8 into asottile:main Jun 2, 2024
3 checks passed
@AlexWaygood AlexWaygood deleted the typing-extensions branch June 2, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants