From 7267887b4ece84af66ef056054867d1a0664a96b Mon Sep 17 00:00:00 2001 From: mferrera Date: Wed, 29 Nov 2023 07:58:04 +0100 Subject: [PATCH] FIX: Union dtypes for Python 3.8 compatibility Even with future annotations imported creating a unioned type of types, using the `type[]` future annotations, caused some errors. --- src/xtgeo/grid3d/grid_property.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/xtgeo/grid3d/grid_property.py b/src/xtgeo/grid3d/grid_property.py index f449afe9c..7f28e2b94 100644 --- a/src/xtgeo/grid3d/grid_property.py +++ b/src/xtgeo/grid3d/grid_property.py @@ -39,6 +39,8 @@ logger = null_logger(__name__) if TYPE_CHECKING: + from typing import Union + import numpy.typing as npt from xtgeo.common.types import FileLike @@ -47,17 +49,17 @@ from ._gridprop_op1 import XYValueLists from .grid import Grid - GridProperty_DType = ( - type[np.uint8] - | type[np.uint16] - | type[np.int16] - | type[np.int32] - | type[np.int64] - | type[np.float16] - | type[np.float32] - | type[np.float64] - ) - Roxar_DType = type[np.uint8] | type[np.uint16] | type[np.float32] + GridProperty_DType = Union[ + type[np.uint8], + type[np.uint16], + type[np.int16], + type[np.int32], + type[np.int64], + type[np.float16], + type[np.float32], + type[np.float64], + ] + Roxar_DType = Union[type[np.uint8], type[np.uint16], type[np.float32]] # -------------------------------------------------------------------------------------- # Comment on 'asmasked' vs 'activeonly: