From 5170ab2a50064705cb59a2ea05448a3f56362a1e Mon Sep 17 00:00:00 2001 From: Cristian Sebastian Rocha Date: Sun, 3 Nov 2024 08:16:25 -0300 Subject: [PATCH] Fix TypeError issue when parse List of objects (#184) 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. --- src/pydantic_yaml/_internals/v2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pydantic_yaml/_internals/v2.py b/src/pydantic_yaml/_internals/v2.py index 12c2786..db99743 100644 --- a/src/pydantic_yaml/_internals/v2.py +++ b/src/pydantic_yaml/_internals/v2.py @@ -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