summaryrefslogtreecommitdiff
path: root/numpy/typing/_shape.py
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-05-24 14:45:49 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-05-27 17:24:04 +0200
commit66fa0481c0dd85d4f90dc56afe3f1b42b96945ad (patch)
tree127daaf75e88eeb5e55bc876e2844f2970ec9700 /numpy/typing/_shape.py
parent89da72353f5e282a36a8e9ad9012400dbe452ced (diff)
downloadnumpy-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.py9
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, ...]