simple enough fix - handle typing.UnionType in additional dtype metadata in json schema

This commit is contained in:
sneakers-the-rat 2024-12-13 17:17:47 -08:00
parent a02d9b2d9c
commit 47d8039819
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D

View file

@ -204,9 +204,15 @@ class NDArray(NPTypingType, metaclass=NDArrayMeta):
json_schema = handler(schema["metadata"])
json_schema = handler.resolve_ref_schema(json_schema)
if not isinstance(dtype, tuple) and dtype.__module__ not in (
if (
not isinstance(dtype, tuple)
and dtype.__module__
not in (
"builtins",
"typing",
"types",
)
and hasattr(dtype, "__name__")
):
json_schema["dtype"] = ".".join([dtype.__module__, dtype.__name__])