Skip to content

Commit

Permalink
Fix TypeError issue when parse List of objects (#184)
Browse files Browse the repository at this point in the history
When try to parse List of objects fails with:

TypeError: issubclass() arg 1 must be a class

Check if model_type is a type solve the issue.
  • Loading branch information
csrocha authored Nov 3, 2024
1 parent 4a6b090 commit 5170ab2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pydantic_yaml/_internals/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def parse_yaml_raw_as(model_type: Type[T], raw: Union[str, bytes, IOBase]) -> T:
raise TypeError(f"Expected str, bytes or IO, but got {raw!r}")
reader = YAML(typ="safe", pure=True) # YAML 1.2 support
objects = reader.load(stream)
if issubclass(model_type, BaseModelV1):
if isinstance(model_type, type) and issubclass(model_type, BaseModelV1):
return parse_obj_as(model_type, objects) # type:ignore
else:
ta = TypeAdapter(model_type) # type: ignore
Expand Down

0 comments on commit 5170ab2

Please sign in to comment.