Generic utilities
Public functions
is_valid_against_reference
is_valid_against_reference(
candidate: object | None,
reference: object,
validator: Callable[..., bool],
) -> bool
Check if 'reference' is falsy or whether it passes the 'validator' check against 'reference'.
parse_timestamp_str_if_set
parse_timestamp_str_if_set(
timestamp_str: str,
) -> datetime | None
are_keys_in_collection
are_keys_in_collection(
dict_: dict, collection: Collection
) -> bool
Check if all keys in a dict are in a collection.
Parameters:
-
(dict_dict) –The dict to check
-
(collectionCollection) –The collection to check against
Returns:
-
bool–True if all keys in the dict are in the collection, False otherwise
are_keys_in_dataclass_fields
are_keys_in_dataclass_fields(
dict_: dict, dataclass_: type
) -> bool
Public classes
TimeRange
dataclass
TimeRange(
start: datetime | None = None,
end: datetime | None = None,
)
Dataclass representing a time range with optional start or end.
Returned by:
-
Glossary
Generic utilities
Public classes
TimeRangefrom_str
Methods:
-
__post_init__–Validate that at least one of start or end is set.
-
from_str–Create a TimeRange instance from ISO format timestamp strings.
-
is_timestamp_in_range–Check if a datetime timestamp is within the time range.
-
is_timestamp_str_in_range–Check if a timestamp string is within the time range.
__post_init__
__post_init__() -> None
Validate that at least one of start or end is set.
Raises:
-
ValueError–If neither start nor end is set.
is_timestamp_str_in_range
is_timestamp_str_in_range(timestamp_str: str) -> bool