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

Add typing_extensions to allow usage of ParamSpec in python < 3.10 #270

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

baluyotraf
Copy link
Contributor

Fixes #269 using the typing_extensions backport.

@patrick-kidger patrick-kidger merged commit 7acd73e into patrick-kidger:main Nov 18, 2024
1 check passed
@patrick-kidger
Copy link
Owner

LGTM - merged! Thank you for the improvement. :)

from typing import ParamSpec
except ImportError:
# Python < 3.10
from typing_extensions import ParamSpec
Copy link

Choose a reason for hiding this comment

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

FYI https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module

import sys
if sys.version_info < (3, 10):
    from typing_extensions import ParamSpec
else:
    from typing import ParamSpec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want me to make another PR with this way of doing it?

Copy link
Owner

Choose a reason for hiding this comment

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

No strong feelings from me! :)

Copy link

Choose a reason for hiding this comment

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

Maybe next time. 😊 The semantics are different, but the main thing is that there's an import guard.

I was vendoring jaxtyping in Arch and noticed a dependency on typing-extensions. Since Arch is rolling release distro, Python is the latest and typing-extension dependency usually can be omitted. It is quite common mistake to import unconditionally typing_extensions or importlib.metadata.

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.

Python 3.9 is no longer supported
3 participants