(value: float | timedelta | Any | None, handler: Callable[[Any], timedelta])
| 32 | |
| 33 | |
| 34 | def _timedelta_from_ms(value: float | timedelta | Any | None, handler: Callable[[Any], timedelta]) -> timedelta | None: |
| 35 | if value == float('inf'): |
| 36 | return timedelta.max |
| 37 | |
| 38 | # If the value is a string-encoded number, decode it |
| 39 | if isinstance(value, str): |
| 40 | with suppress(ValidationError): |
| 41 | value = _number_parser.validate_python(value) |
| 42 | |
| 43 | if not isinstance(value, (int, float)): |
| 44 | return handler(value) |
| 45 | |
| 46 | return timedelta(milliseconds=value) |
| 47 | |
| 48 | |
| 49 | def _timedelta_from_secs( |