Skip to content

Commit

Permalink
Fixed small bug for numpy generics
Browse files Browse the repository at this point in the history
  • Loading branch information
sg495 committed Jan 30, 2024
1 parent 3d29107 commit 644bab5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions typing_validation/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,6 @@ def _extract_dtypes(t: Any) -> typing.Sequence[Any]:
dtype for member in t.__args__ for dtype in _extract_dtypes(member)
]
import numpy as np # pylint: disable = import-outside-toplevel

if isinstance(t, type) and issubclass(t, np.generic):
return [t]
if hasattr(t, "__origin__"):
t_origin = t.__origin__
if t_origin in {
Expand All @@ -532,6 +529,8 @@ def _extract_dtypes(t: Any) -> typing.Sequence[Any]:
if t == t_origin[Any]:
return [t_origin]
# TODO: add broader support for np.NBitBase subtypes
if isinstance(t, type) and issubclass(t, np.generic):
return [t]
raise TypeError()


Expand Down

0 comments on commit 644bab5

Please sign in to comment.