Skip to content

Commit

Permalink
tag: only import typing_extensions when TYPE_CHECKING
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl committed Aug 6, 2024
1 parent 5a76aa3 commit 9e80a1d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pytools/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@
from warnings import warn


try:
from typing import Self, dataclass_transform
except ImportError:
if TYPE_CHECKING:
# NOTE: mypy seems to be confused by the `try.. except` below when called with
# python -m mypy --python-version 3.8 ...
# see https://github.com/python/mypy/issues/14220
from typing_extensions import Self, dataclass_transform
else:
try:
from typing import Self, dataclass_transform
except ImportError:
from typing_extensions import Self, dataclass_transform

from pytools import memoize, memoize_method

Expand Down

0 comments on commit 9e80a1d

Please sign in to comment.