mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
use object for typing since these functions accept other types
This commit is contained in:
10
jc/utils.py
10
jc/utils.py
@ -179,7 +179,7 @@ def has_data(data: Union[str, bytes]) -> bool:
|
|||||||
return bool(data)
|
return bool(data)
|
||||||
|
|
||||||
|
|
||||||
def convert_to_int(value: Union[str, float]) -> Optional[int]:
|
def convert_to_int(value: object) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
Converts string and float input to int. Strips all non-numeric
|
Converts string and float input to int. Strips all non-numeric
|
||||||
characters from strings.
|
characters from strings.
|
||||||
@ -209,7 +209,7 @@ def convert_to_int(value: Union[str, float]) -> Optional[int]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def convert_to_float(value: Union[str, int]) -> Optional[float]:
|
def convert_to_float(value: object) -> Optional[float]:
|
||||||
"""
|
"""
|
||||||
Converts string and int input to float. Strips all non-numeric
|
Converts string and int input to float. Strips all non-numeric
|
||||||
characters from strings.
|
characters from strings.
|
||||||
@ -235,7 +235,7 @@ def convert_to_float(value: Union[str, int]) -> Optional[float]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def convert_to_bool(value: Union[str, int, float]) -> bool:
|
def convert_to_bool(value: object) -> bool:
|
||||||
"""
|
"""
|
||||||
Converts string, integer, or float input to boolean by checking
|
Converts string, integer, or float input to boolean by checking
|
||||||
for 'truthy' values.
|
for 'truthy' values.
|
||||||
@ -283,7 +283,7 @@ class timestamp:
|
|||||||
__slots__ = ('string', 'format', 'naive', 'utc')
|
__slots__ = ('string', 'format', 'naive', 'utc')
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
datetime_string: str,
|
datetime_string: Optional[str],
|
||||||
format_hint: Optional[Iterable[int]] = None
|
format_hint: Optional[Iterable[int]] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
@ -333,7 +333,7 @@ class timestamp:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@lru_cache(maxsize=512)
|
@lru_cache(maxsize=512)
|
||||||
def _parse_dt(
|
def _parse_dt(
|
||||||
dt_string: str,
|
dt_string: Optional[str],
|
||||||
format_hint: Optional[Iterable[int]] = None
|
format_hint: Optional[Iterable[int]] = None
|
||||||
) -> Dict[str, Optional[int]]:
|
) -> Dict[str, Optional[int]]:
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user