| 157 | |
| 158 | def 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 |
no outgoing calls