diff options
author | Bas van Beek <b.f.van.beek@vu.nl> | 2021-05-24 14:45:49 +0200 |
---|---|---|
committer | Bas van Beek <b.f.van.beek@vu.nl> | 2021-05-27 17:24:04 +0200 |
commit | 66fa0481c0dd85d4f90dc56afe3f1b42b96945ad (patch) | |
tree | 127daaf75e88eeb5e55bc876e2844f2970ec9700 /numpy/typing/_shape.py | |
parent | 89da72353f5e282a36a8e9ad9012400dbe452ced (diff) | |
download | numpy-66fa0481c0dd85d4f90dc56afe3f1b42b96945ad.tar.gz |
ENH: Add a global constant to `numpy.typing` denoting whether or not `typing_extensions` is available
Diffstat (limited to 'numpy/typing/_shape.py')
-rw-r--r-- | numpy/typing/_shape.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/numpy/typing/_shape.py b/numpy/typing/_shape.py index b720c3ffc..0742be8a9 100644 --- a/numpy/typing/_shape.py +++ b/numpy/typing/_shape.py @@ -1,13 +1,14 @@ import sys from typing import Sequence, Tuple, Union +from . import _HAS_TYPING_EXTENSIONS + if sys.version_info >= (3, 8): from typing import SupportsIndex +elif _HAS_TYPING_EXTENSIONS: + from typing_extensions import SupportsIndex else: - try: - from typing_extensions import SupportsIndex - except ImportError: - SupportsIndex = NotImplemented + SupportsIndex = NotImplemented _Shape = Tuple[int, ...] |