Skip to content

Commit

Permalink
"Fix" some typing shims for 3.10+.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachaa-Thanasius committed Oct 3, 2024
1 parent c74e3b4 commit ce4f0c1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/defer_imports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ def _final(f: object) -> object:


if sys.version_info >= (3, 10): # pragma: >=3.10 cover
_TypeAlias: typing.TypeAlias = "typing.TypeAlias"
_TypeGuard: typing.TypeAlias = "typing.TypeGuard"
if TYPE_CHECKING:
from typing import TypeAlias as _TypeAlias, TypeGuard as _TypeGuard
else:
_TypeAlias: typing.TypeAlias = "typing.TypeAlias"
_TypeGuard: typing.TypeAlias = "typing.TypeGuard"
elif TYPE_CHECKING:
from typing_extensions import TypeAlias as _TypeAlias, TypeGuard as _TypeGuard
else: # pragma: <3.10 cover
Expand All @@ -157,7 +160,10 @@ class _TypeGuard(metaclass=_PlaceholderMeta):


if sys.version_info >= (3, 11): # pragma: >=3.11 cover
_Self: _TypeAlias = "typing.Self"
if TYPE_CHECKING:
from typing import Self as _Self
else:
_Self: _TypeAlias = "typing.Self"
elif TYPE_CHECKING:
from typing_extensions import Self as _Self
else: # pragma: <3.11 cover
Expand Down

0 comments on commit ce4f0c1

Please sign in to comment.