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 UP035 for Python 3.13 #11413

Closed
AlexWaygood opened this issue May 13, 2024 · 2 comments · Fixed by #11693
Closed

Update UP035 for Python 3.13 #11413

AlexWaygood opened this issue May 13, 2024 · 2 comments · Fixed by #11693
Labels
python313 Related to Python 3.13 rule Implementing or modifying a lint rule

Comments

@AlexWaygood
Copy link
Member

We should update UP035 to emit a diagnostic if --target-version=py313 has been selected and a user imports typing.TypeIs, warnings.deprecated, typing.ReadOnly, typing.NoDefault typing.get_protocol_members or typing.is_protocol from typing_extensions rather than typing

Originally posted by @AlexWaygood in #11411 (comment)

@AlexWaygood AlexWaygood added the rule Implementing or modifying a lint rule label May 13, 2024
@AlexWaygood
Copy link
Member Author

AlexWaygood commented May 13, 2024

Other updates that are required

  • We should emit an error if TypeVar, ParamSpec or TypeVarTuple is imported from typing_extensions and the script targets py313+ (but not if the script targets lower versions)
  • We should not emit an error if the script targets py312 or lower, and any of TypedDict, Protocol, runtime_checkable or get_type_hints is imported from typing_extensions. These all have their implementations from Python 3.13 backported in typing_extensions. (We currently do emit errors for all of these; this is a false positive.)

@AlexWaygood
Copy link
Member Author

AlexWaygood commented May 13, 2024

Lastly, for (Async)Generator and (Async)ContextManager, we should recommend for the user to import them from collections.abc or contextlib rather than typing_extensions on Python 3.9-3.12 (and not emit a diagnostic at all on Python <=3.8). Currently if we see a user importing then from typing_extensions, we tell the user to import them from typing instead, but that's no longer a good suggestion. The typing_extensions versions backport the typing versions from Python 3.13, but on Python 3.9-3.12, the collections.abc/contextlib versions should still be a dropin replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python313 Related to Python 3.13 rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants