diff options
Diffstat (limited to 'numpy/typing/_char_codes.py')
-rw-r--r-- | numpy/typing/_char_codes.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/numpy/typing/_char_codes.py b/numpy/typing/_char_codes.py index 6b6f7ae88..24d39c62e 100644 --- a/numpy/typing/_char_codes.py +++ b/numpy/typing/_char_codes.py @@ -1,18 +1,14 @@ import sys from typing import Any, TYPE_CHECKING +from . import _HAS_TYPING_EXTENSIONS + if sys.version_info >= (3, 8): from typing import Literal - HAVE_LITERAL = True -else: - try: - from typing_extensions import Literal - except ImportError: - HAVE_LITERAL = False - else: - HAVE_LITERAL = True - -if TYPE_CHECKING or HAVE_LITERAL: +elif _HAS_TYPING_EXTENSIONS: + from typing_extensions import Literal + +if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS: _BoolCodes = Literal["?", "=?", "<?", ">?", "bool", "bool_", "bool8"] _UInt8Codes = Literal["uint8", "u1", "=u1", "<u1", ">u1"] |