Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
hub
/
github.com/pydantic/pydantic
/ y_str
Method
y_str
tests/test_computed_fields.py:337–339 ·
view source on GitHub ↗
(self)
Source
from the content-addressed store, hash-verified
335
336
@computed_field
337
def
y_str(self) -> bytes:
338
s = f
'y={self.y}'
339
return
s.encode()
340
341
m = Model(x=1, y=2)
342
assert m.model_dump() == {
'x'
: 1,
'y'
: 2,
'x_list'
: [1, 2],
'y_str'
: b
'y=2'
}
Callers
nothing calls this directly
Calls
1
encode
Method · 0.45
Tested by
no test coverage detected