It seems like IsInstance will never be equal to a pydantic model:
from dirty_equals import IsInstance
from pydantic import BaseModel
class A(BaseModel): pass
print(A() == IsInstance(A)) # False
print(A() == IsInstance[A]) # False
class B: pass
print(B() == IsInstance(B)) # True
print(B() == IsInstance[B]) # True
Interestingly enough it works perfectly with IsPartialDict:
from dirty_equals import IsPartialDict, IsNegativeInt
from pydantic import BaseModel
class C(BaseModel):
a: int
b: str
print(C(a=-1,b="a") == IsPartialDict(a=IsNegativeInt)) # True
print(C(a=-1,b="a") == IsPartialDict(a=IsNegativeInt, b=1)) # False
Maybe it's also nice to document that IsPartialDict works with pydantic models without having to call model_instance.dict()?
Tested with dirty-equals version 0.50 and pydantic versions 1.9.0 and 1.10.7.
It seems like
IsInstancewill never be equal to a pydantic model:Interestingly enough it works perfectly with
IsPartialDict:Maybe it's also nice to document that
IsPartialDictworks with pydantic models without having to callmodel_instance.dict()?Tested with dirty-equals version 0.50 and pydantic versions 1.9.0 and 1.10.7.