MCPcopy
hub / github.com/openai/openai-python / _get_numeric

Function _get_numeric

src/openai/_utils/_datetime_parse.py:33–41  ·  view source on GitHub ↗
(value: StrBytesIntFloat, native_expected_type: str)

Source from the content-addressed store, hash-verified

31
32
33def _get_numeric(value: StrBytesIntFloat, native_expected_type: str) -> Union[None, int, float]:
34 if isinstance(value, (int, float)):
35 return value
36 try:
37 return float(value)
38 except ValueError:
39 return None
40 except TypeError:
41 raise TypeError(f"invalid type; expected {native_expected_type}, string, bytes, int or float") from None
42
43
44def _from_unix_seconds(seconds: Union[int, float]) -> datetime:

Callers 2

parse_datetimeFunction · 0.85
parse_dateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected