MCPcopy
hub / github.com/pydantic/pydantic / SubDt

Class SubDt

tests/test_json.py:159–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157
158def test_subclass_custom_encoding():
159 class SubDt(datetime):
160 @classmethod
161 def __get_pydantic_core_schema__(cls, source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema:
162 def val(v: datetime) -> SubDt:
163 return SubDt.fromtimestamp(v.timestamp())
164
165 return core_schema.no_info_after_validator_function(val, handler(datetime))
166
167 class SubDelta(timedelta):
168 @classmethod

Callers 1

Calls

no outgoing calls

Tested by 1