MCPcopy
hub / github.com/pydantic/pydantic / SubDate

Class SubDate

tests/test_json.py:141–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139
140def test_subclass_encoding():
141 class SubDate(datetime):
142 @classmethod
143 def __get_pydantic_core_schema__(cls, source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema:
144 def val(v: datetime) -> SubDate:
145 return SubDate.fromtimestamp(v.timestamp())
146
147 return core_schema.no_info_after_validator_function(val, handler(datetime))
148
149 class Model(BaseModel):
150 a: datetime

Callers 1

test_subclass_encodingFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_subclass_encodingFunction · 0.68