Automatically and lazily generate three versions of your pydantic models: one with Extra.forbid, one with Extra.ignore, and one with all fields optional
>>> from pydantic_duality import DualBaseModel
>>> class M(DualBaseModel):
... a: list[str]
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jvstme/git/dstack/dstack/temp/venv/lib64/python3.10/site-packages/pydantic_duality/__init__.py", line 138, in __new__
new_class._generate_alternative_classes(
File "/home/jvstme/git/dstack/dstack/temp/venv/lib64/python3.10/site-packages/pydantic_duality/__init__.py", line 171, in _generate_alternative_classes
_alter_attrs(attrs, name + request_suffix, REQUEST_ATTR),
File "/home/jvstme/git/dstack/dstack/temp/venv/lib64/python3.10/site-packages/pydantic_duality/__init__.py", line 73, in _alter_attrs
annotations[key] = _resolve_annotation(val, attr)
File "/home/jvstme/git/dstack/dstack/temp/venv/lib64/python3.10/site-packages/pydantic_duality/__init__.py", line 51, in _resolve_annotation
if inspect.isclass(annotation) and issubclass(annotation, BaseModel):
File "/usr/lib64/python3.10/abc.py", line 123, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class
Expected behavior
Using built-in collections for annotations is expected to be equivalent to using the (now deprecated) typing.* types.
>>> from pydantic_duality import DualBaseModel
>>> from typing import List
>>> class M(DualBaseModel):
... a: List[str]
...
>>>
Additional context
Looks like the issue was introduced in pydantic-duality==1.2.0. The same example works fine with pydantic-duality==1.1.1
To Reproduce
Expected behavior Using built-in collections for annotations is expected to be equivalent to using the (now deprecated)
typing.*
types.Additional context Looks like the issue was introduced in
pydantic-duality==1.2.0
. The same example works fine withpydantic-duality==1.1.1