MCPcopy
hub / github.com/pydantic/pydantic / Rectangle

Class Rectangle

tests/test_computed_fields.py:28–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27def test_computed_fields_get():
28 class Rectangle(BaseModel):
29 width: int
30 length: int
31
32 @computed_field
33 def area(self) -> int:
34 """An awesome area"""
35 return self.width * self.length
36
37 @computed_field(title='Pikarea', description='Another area')
38 @property
39 def area2(self) -> int:
40 return self.width * self.length
41
42 @property
43 def double_width(self) -> int:
44 return self.width * 2
45
46 rect = Rectangle(width=10, length=5)
47 assert set(Rectangle.model_fields) == {'width', 'length'}

Callers 1

test_computed_fields_getFunction · 0.70

Calls

no outgoing calls

Tested by 1

test_computed_fields_getFunction · 0.56