Skip to content

Commit

Permalink
simple enough fix - handle typing.UnionType in additional dtype m…
Browse files Browse the repository at this point in the history
…etadata in json schema
  • Loading branch information
sneakers-the-rat committed Dec 14, 2024
1 parent a02d9b2 commit 47d8039
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/numpydantic/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,15 @@ def __get_pydantic_json_schema__(
json_schema = handler(schema["metadata"])
json_schema = handler.resolve_ref_schema(json_schema)

if not isinstance(dtype, tuple) and dtype.__module__ not in (
"builtins",
"typing",
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__])

Expand Down

0 comments on commit 47d8039

Please sign in to comment.