Update pydantic-duality to fix the infinite recursion bug#1902
Update pydantic-duality to fix the infinite recursion bug#1902jvstme merged 1 commit intodstackai:masterfrom
Conversation
|
NOTICE that I dropped support for python 3.8 as it reached its EOL. Is that fine with you? |
|
cc @jvstme on Python 3.8 |
|
@zmievsa, thanks for the writeup and the fix! We're going to support 3.13 and drop 3.8 also, so that's fine. Regarding the issue, I have a hypothesis what can be the root cause:
This is due to this The problem only appears if there is any other So the behaviour does not depend on any import abc
from pydantic import BaseModel
from pydantic_duality import DualBaseModel
class AzureStoredConfig(DualBaseModel):
resource_group: str
class MyMeta(metaclass=abc.ABCMeta):
pass
MyMeta.register(int)
class AzureConfig(AzureStoredConfig, BaseModel):
pass
class GCPVolumeDiskBackendData(DualBaseModel):
disk_type: str |
|
@r4victor nice catch! You are likely right. |
bd2a91b to
d21b0ab
Compare
It was a long one. Here's the entire process for the fix:
Resolves zmievsa/pydantic-duality#21
I am still not sure what exactly is causing the bug but here's what happens:
DualBaseModel.__response__in subclass checks, the response model gets generated (exactly once though) during the very first subclass checkissubclass(annotation, pydantic.BaseModel). The specific class that caused the issue here isstrsoissubclass(str, pydantic.BaseModel)DualBaseModel.__subclasshook__instead of usingBaseModel's ortype's default subclass check. Not sure how it is possible but I verified that everything from the code block above is absolutely necessary for this situation to happen