Skip to content

Commit

Permalink
Exception for Number before Python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Aug 9, 2023
1 parent d054bb7 commit 28966ee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions geoutils/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

import numpy as np

# Mypy has issues with the builtin Number type (https://github.com/python/mypy/issues/3186)
Number = Union[int, float, np.integer[Any], np.floating[Any]]

# Only for Python >= 3.9
if sys.version_info.minor >= 9:

Expand All @@ -18,6 +15,9 @@
NDArray,
)

# Mypy has issues with the builtin Number type (https://github.com/python/mypy/issues/3186)
Number = Union[int, float, np.integer[Any], np.floating[Any]]

# Simply define here if they exist
DTypeLike = DTypeLike
ArrayLike = ArrayLike
Expand All @@ -32,6 +32,9 @@
# For backward compatibility before Python 3.9
else:

# Mypy has issues with the builtin Number type (https://github.com/python/mypy/issues/3186)
Number = Union[int, float, np.integer, np.floating] # type: ignore

# Make an array-like type (since the array-like numpy type only exists in numpy>=1.20)
ArrayLike = Union[np.ndarray, np.ma.masked_array, List[Any], Tuple[Any]] # type: ignore
DTypeLike = Union[str, type, np.dtype] # type: ignore
Expand Down

0 comments on commit 28966ee

Please sign in to comment.