MCPcopy
hub / github.com/pydantic/pydantic / id

Method id

tests/test_computed_fields.py:818–821  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

816 @computed_field
817 @property
818 def id(self) -> str:
819 str_obj = self.model_dump_json(exclude={'id'})
820 # you could imagine hashing str_obj, etc. but for simplicity, just wrap it in a descriptive string
821 return f'id: {str_obj}'
822
823 m = Model(bar=42)
824 assert m.model_dump() == {'bar': 42, 'id': 'id: {"bar":42}'}

Callers

nothing calls this directly

Calls 1

model_dump_jsonMethod · 0.80

Tested by

no test coverage detected