MCPcopy
hub / github.com/pydantic/pydantic / get_numeric

Function get_numeric

pydantic/v1/datetime_parse.py:66–74  ·  view source on GitHub ↗
(value: StrBytesIntFloat, native_expected_type: str)

Source from the content-addressed store, hash-verified

64
65
66def get_numeric(value: StrBytesIntFloat, native_expected_type: str) -> Union[None, int, float]:
67 if isinstance(value, (int, float)):
68 return value
69 try:
70 return float(value)
71 except ValueError:
72 return None
73 except TypeError:
74 raise TypeError(f'invalid type; expected {native_expected_type}, string, bytes, int or float')
75
76
77def from_unix_seconds(seconds: Union[int, float]) -> datetime:

Callers 3

parse_dateFunction · 0.85
parse_timeFunction · 0.85
parse_datetimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected