Skip to content

Commit

Permalink
some formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasaarholt committed Oct 22, 2024
1 parent 6da1250 commit 02f6eba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/patito/_pydantic/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def _pydantic_subschema_to_valid_polars_types(
self.defs[props["$ref"].split("/")[-1]]
)
return DataTypeGroup([])

pyd_type = props.get("type")
if pyd_type == "array":
if "items" not in props:
Expand All @@ -170,6 +171,7 @@ def _pydantic_subschema_to_valid_polars_types(
return DataTypeGroup(
[pl.List(dtype) for dtype in item_dtypes], match_base_type=False
)

elif pyd_type == "object":
if "properties" not in props:
return DataTypeGroup([])
Expand All @@ -179,7 +181,6 @@ def _pydantic_subschema_to_valid_polars_types(
dtype = self._default_polars_dtype_for_schema(sub_props)
assert dtype is not None
struct_fields.append(pl.Field(name, dtype))

return DataTypeGroup(
[pl.Struct(struct_fields)],
match_base_type=False,
Expand Down Expand Up @@ -247,6 +248,7 @@ def _pydantic_subschema_to_default_dtype(
)
object_props: dict[str, dict[str, str]] = props["properties"]
struct_fields: list[pl.Field] = []

for name, sub_props in object_props.items():
dtype = self._default_polars_dtype_for_schema(sub_props)
assert dtype is not None
Expand Down

0 comments on commit 02f6eba

Please sign in to comment.