From 850609f658024b44d00eb869acef8764f3ee9177 Mon Sep 17 00:00:00 2001 From: mferrera Date: Thu, 9 Nov 2023 19:41:47 +0100 Subject: [PATCH] Type-check guard `numpy.typing` import Numpy versions less than 1.20 do not have the typing module. --- src/resfo/types.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/resfo/types.py b/src/resfo/types.py index fa5a43d..cb7ed24 100644 --- a/src/resfo/types.py +++ b/src/resfo/types.py @@ -23,10 +23,12 @@ """ import warnings -from typing import Union +from typing import TYPE_CHECKING, Union import numpy as np -from numpy.typing import ArrayLike + +if TYPE_CHECKING: + from numpy.typing import ArrayLike # np dtype for res types with fixed width static_dtypes = { @@ -48,7 +50,7 @@ class MESS: ReadArrayValue = Union[np.ndarray, MESS] -WriteArrayValue = Union[ArrayLike, MESS] +WriteArrayValue = Union["ArrayLike", MESS] def to_np_type(type_keyword):