mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
type annotation updates
This commit is contained in:
@ -225,7 +225,7 @@ def plugin_parser_mod_list() -> List[str]:
|
|||||||
"""
|
"""
|
||||||
return [_cliname_to_modname(p) for p in local_parsers]
|
return [_cliname_to_modname(p) for p in local_parsers]
|
||||||
|
|
||||||
def parser_info(parser_mod_name: str) -> Union[Dict, None]:
|
def parser_info(parser_mod_name: str) -> Optional[Dict]:
|
||||||
"""
|
"""
|
||||||
Returns a dictionary that includes the module metadata.
|
Returns a dictionary that includes the module metadata.
|
||||||
|
|
||||||
|
36
jc/utils.py
36
jc/utils.py
@ -5,7 +5,7 @@ import locale
|
|||||||
import shutil
|
import shutil
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
from typing import Dict, Iterable, List, Union
|
from typing import Dict, Iterable, List, Union, Optional
|
||||||
|
|
||||||
|
|
||||||
def warning_message(message_lines: List[str]) -> None:
|
def warning_message(message_lines: List[str]) -> None:
|
||||||
@ -127,7 +127,7 @@ def has_data(data: str) -> bool:
|
|||||||
return bool(data and not data.isspace())
|
return bool(data and not data.isspace())
|
||||||
|
|
||||||
|
|
||||||
def convert_to_int(value: Union[str, float]) -> Union[int, None]:
|
def convert_to_int(value: Union[str, float]) -> 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.
|
||||||
@ -157,7 +157,7 @@ def convert_to_int(value: Union[str, float]) -> Union[int, None]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def convert_to_float(value: Union[str, int]) -> Union[float, None]:
|
def convert_to_float(value: Union[str, int]) -> 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.
|
||||||
@ -277,23 +277,21 @@ class timestamp:
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
datetime_string: (str) a string representation of a
|
datetime_string (str): a string representation of a
|
||||||
date-time in several supported formats
|
datetime in several supported formats
|
||||||
|
|
||||||
Attributes:
|
Returns a timestamp object with the following attributes:
|
||||||
|
|
||||||
string (str) the input datetime string
|
string (str): the input datetime string
|
||||||
|
|
||||||
format (int) the format rule that was used to
|
format (int | None): the format rule that was used to decode
|
||||||
decode the datetime string. None if
|
the datetime string. None if conversion fails.
|
||||||
conversion fails
|
|
||||||
|
|
||||||
naive (int) timestamp based on locally configured
|
naive (int | None): timestamp based on locally configured
|
||||||
timezone. None if conversion fails
|
timezone. None if conversion fails.
|
||||||
|
|
||||||
utc (int) aware timestamp only if UTC timezone
|
utc (int | None) aware timestamp only if UTC timezone
|
||||||
detected in datetime string. None if
|
detected in datetime string. None if conversion fails.
|
||||||
conversion fails
|
|
||||||
"""
|
"""
|
||||||
self.string = datetime_string
|
self.string = datetime_string
|
||||||
dt = self._parse()
|
dt = self._parse()
|
||||||
@ -316,19 +314,19 @@ class timestamp:
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary A Dictionary of the following format:
|
Dictionary of the following format:
|
||||||
|
|
||||||
{
|
{
|
||||||
# for debugging purposes. None if conversion fails
|
# for debugging purposes. None if conversion fails
|
||||||
"format": integer,
|
"format": int,
|
||||||
|
|
||||||
# timestamp based on locally configured timezone.
|
# timestamp based on locally configured timezone.
|
||||||
# None if conversion fails.
|
# None if conversion fails.
|
||||||
"timestamp_naive": integer,
|
"timestamp_naive": int,
|
||||||
|
|
||||||
# aware timestamp only if UTC timezone detected.
|
# aware timestamp only if UTC timezone detected.
|
||||||
# None if conversion fails.
|
# None if conversion fails.
|
||||||
"timestamp_utc": integer
|
"timestamp_utc": int
|
||||||
}
|
}
|
||||||
|
|
||||||
The `format` integer denotes which date_time format
|
The `format` integer denotes which date_time format
|
||||||
|
Reference in New Issue
Block a user