Skip to content

Commit

Permalink
Fix data_from_type with None type
Browse files Browse the repository at this point in the history
  • Loading branch information
christiansandberg committed Oct 1, 2024
1 parent dde1b64 commit 98406fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions onedm/sdf/from_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def data_from_type(type_: Type) -> data.Data | None:
None or null is not a supported type in SDF. In this case the return value
will be None.
"""
if type_ is None:
return None
return data_from_schema(TypeAdapter(type_).core_schema)


def data_from_schema(schema: core_schema.CoreSchema) -> data.Data:
def data_from_schema(schema: core_schema.CoreSchema) -> data.Data | None:
schema_type = schema["type"]
data_type: data.Data
if schema_type == "none":
return None
if schema_type == "nullable":
data_type = data_from_nullable_schema(schema) # type: ignore
elif schema_type == "default":
Expand Down

0 comments on commit 98406fa

Please sign in to comment.