Skip to content

Commit d1e82b5

Browse files
check type attribute in dtype check
1 parent d763d8f commit d1e82b5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/numpydantic/validation/dtype.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ def validate_dtype(dtype: Any, target: DtypeType) -> bool:
4747
try:
4848
valid = issubclass(dtype, target)
4949
except TypeError:
50-
# expected, if dtype or target is not a class
51-
valid = dtype == target
50+
# error expected if dtype or target is not a class
51+
# main type check - directly test dtype identity
52+
valid = dtype == target or getattr(dtype, "type", None) == target
5253

5354
return valid
5455

0 commit comments

Comments
 (0)