Skip to content

Commit

Permalink
Unconditionally depend on typing-extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Oct 8, 2024
1 parent 7caa81a commit 7ae0962
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ classifiers = [
dependencies = [
"platformdirs>=2.2",
# for dataclass_transform with frozen_default
"typing-extensions>=4; python_version<'3.13'",
"typing-extensions>=4",
]

[project.optional-dependencies]
Expand Down
18 changes: 1 addition & 17 deletions pytools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from functools import reduce, wraps
from sys import intern
from typing import (
TYPE_CHECKING,
Any,
Callable,
ClassVar,
Expand All @@ -52,22 +51,7 @@
Union,
)


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 Concatenate, ParamSpec, SupportsIndex
else:
try:
from typing import Concatenate, SupportsIndex
except ImportError:
from typing_extensions import Concatenate, SupportsIndex

try:
from typing import ParamSpec
except ImportError:
from typing_extensions import ParamSpec # type: ignore[assignment]
from typing_extensions import Concatenate, ParamSpec, SupportsIndex


# These are deprecated and will go away in 2022.
Expand Down
13 changes: 1 addition & 12 deletions pytools/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@

from dataclasses import dataclass
from typing import (
TYPE_CHECKING,
Any,
Callable,
Collection,
Expand All @@ -89,17 +88,7 @@
TypeVar,
)


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 TypeAlias
else:
try:
from typing import TypeAlias
except ImportError:
from typing_extensions import TypeAlias
from typing_extensions import TypeAlias


NodeT = TypeVar("NodeT", bound=Hashable)
Expand Down
12 changes: 1 addition & 11 deletions pytools/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,7 @@
)
from warnings import warn


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 typing_extensions import Self, dataclass_transform

from pytools import memoize, memoize_method

Expand Down

0 comments on commit 7ae0962

Please sign in to comment.