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

DEP: Ensure typing_extension is dependency for earlier python versions #290

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

mgxd
Copy link
Contributor

@mgxd mgxd commented Oct 2, 2024

The following guard hits a ModuleNotFoundError on a fresh 3.10 environment

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

This PR adds typing_extension as an optional dependency for earlier Python versions.

Copy link
Collaborator

@ap-- ap-- left a comment

Choose a reason for hiding this comment

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

Thank you @mgxd for the PR and good catch! No idea how we missed this before...

I'd like to avoid requiring typing_extensions as a runtime dependency. It's only required during type checking.

Could you make changes to your PR and guard the typing.Self import block with if TYPE_CHECKING?

if TYPE_CHECKING:
    if sys.version_info >= (3, 11):
        from typing import Self
    else:
        from typing_extensions import Self

We'd need this in the three places below:

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

Thanks!
Andreas

@mgxd
Copy link
Contributor Author

mgxd commented Oct 3, 2024

@ap-- went ahead with your suggestion - also moved the selective typing_extensions into the dev extra.

Copy link
Collaborator

@ap-- ap-- left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@ap-- ap-- merged commit 6450ef8 into fsspec:main Oct 3, 2024
22 checks passed
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