Hash nested model fields by immutable value
This commit is contained in:
parent
a79c65757f
commit
48324403bb
1 changed files with 29 additions and 1 deletions
|
|
@ -3,4 +3,6 @@ from pydantic import BaseModel
|
|||
|
||||
class HashableBaseModel(BaseModel):
|
||||
def __hash__(self) -> int:
|
||||
return hash((type(self),) + tuple(self.__dict__.values()))
|
||||
from ..helper.frozen_call import make_hashable
|
||||
|
||||
return hash(make_hashable(self))
|
||||
|
|
|
|||
Loading…
Reference in a new issue