Closed r4victor closed 2 weeks ago
Hm... I remember explicitly adding the feature to make sure this behavior is impossible. I'll take a look.
I looked into it. I did do this for reverse checks ( isinstance(obj, cls.__request__)
) but not for the other types of checks. The current architecture is based on building completely different MRO for each object (where cls.__request__
is based on the .__request__
of its parents, and so on) which means that the classes you are trying to compare are completely unrelated.
A completely different architecture seems to be necessary to fix the issue you are referencing. Do you have any ideas?
Fixed in 1.2.3. Please, check.
Describe the bug We're parsing objects using
MyModel.__response__
, then pass the objects as if they were instances ofMyModel
. This fails becauseisinstance(obj, MyModel)
returnFalse
.To Reproduce Steps to reproduce the behavior:
DualBaseModel
__response__
.isinstance()
. The check fails:Expected behavior I'm not sure if this is intended or not and if it should be considered a bug in pydantic-duality, but such behavior was unexpected – it requires to always check for both
isinstance(obj, MyModel)
andisinstance(obj, MyModel.__response__)
when the code works with objects parsed byMyModel.__response__
.Screenshots If applicable, add screenshots to help explain your problem.
Operating system macOS
Additional context Add any other context about the problem here.