Error when parse List of objects using parse_yaml_raw_as
csrocha opened this issue · comments
Cristian Sebastian Rocha commented
Example:
from typing import List
from pydantic import BaseModel
from pydantic_yaml import parse_yaml_raw_as
class Dimension(BaseModel):
name: str
group: str
test_yaml = """
- apertura: male
dimension: Sex
- apertura: female
dimension: Sex
"""
dimensions = parse_yaml_raw_as(List[Dimension], test_yaml)
Code fails with:
File "c:\Users\csroc\Proyects\geoecon\metadata\.venv\Lib\site-packages\pydantic_yaml\_internals\v2.py", line 238, in parse_yaml_raw_as
if issubclass(model_type, BaseModelV1):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\abc.py", line 123, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class
Adam Morris commented
I believe this is the same issue reported previously here