Merge pull request #1 from radarhere/bug/compat/numpy1.20

Do not import numpy.typing unless TYPE_CHECKING
This commit is contained in:
Clément Robert 2024-07-02 12:00:01 +02:00 committed by GitHub
commit ce6fb1279f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,14 +2,15 @@ from __future__ import annotations
import os import os
import sys import sys
from typing import Any, Protocol, Sequence, TypeVar, Union from typing import TYPE_CHECKING, Any, Protocol, Sequence, TypeVar, Union
try: if TYPE_CHECKING:
import numpy.typing as npt try:
import numpy.typing as npt
NumpyArray = npt.NDArray[Any] # requires numpy>=1.21 NumpyArray = npt.NDArray[Any] # requires numpy>=1.21
except (ImportError, AttributeError): except (ImportError, AttributeError):
pass pass
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
from typing import TypeGuard from typing import TypeGuard