extended_data.primitives.state¶
The state_utils module provides utility functions for handling and evaluating data structure “emptiness”.
It includes functions to determine whether a value is considered “nothing”, to extract non-empty values, and to assess the state of provided arguments and keyword arguments.
Functions: - is_nothing: Determines if a value is considered “nothing” (e.g., None, empty string, empty list, empty dict). - are_nothing: Checks if all provided values (both positional and keyword arguments) are “nothing”. - all_non_empty: Returns all non-empty values from provided arguments and keyword arguments. - all_non_empty_in_list: Returns a list of non-empty values from the provided list. - all_non_empty_in_dict: Returns a dictionary of non-empty values from the provided dictionary. - first_non_empty: Retrieves the first non-empty value from a set of provided values. - any_non_empty: Retrieves the first non-empty value from a mapping for a given set of keys. - yield_non_empty: Yields non-empty values from a mapping for a given set of keys.
Module Contents¶
Functions¶
Checks if a value is considered ‘nothing’. |
|
Checks if all provided values (both args and kwargs) are considered ‘nothing’. |
|
Returns all non-empty values from the provided args and kwargs. |
|
Returns a list of all non-empty values from the input list. |
|
Returns a dictionary of all non-empty values from the input dictionary. |
|
Returns the first non-empty value. |
|
Returns the first non-empty value from a mapping for the given keys. |
|
Yields non-empty values from a mapping for the given keys. |
API¶
- extended_data.primitives.state.is_nothing(v: Any) bool¶
Checks if a value is considered ‘nothing’.
Args: v (Any): The value to check.
Returns: bool: True if the value is considered ‘nothing’, False otherwise.
- extended_data.primitives.state.are_nothing(*args: Any, **kwargs: Any) bool¶
Checks if all provided values (both args and kwargs) are considered ‘nothing’.
Args: args (Any): Positional arguments to check. kwargs (Any): Keyword arguments to check.
Returns: bool: True if all values are considered ‘nothing’, False otherwise.
- extended_data.primitives.state.all_non_empty(*args: Any, **kwargs: Any) list[Any] | dict[str, Any] | tuple[list[Any], dict[str, Any]] | None¶
Returns all non-empty values from the provided args and kwargs.
Args: args (Any): Positional arguments to check. kwargs (Any): Keyword arguments to check.
Returns: Union[List[Any], Dict[str, Any], Tuple[List[Any], Dict[str, Any]], None]: A list, dict, tuple of list
- extended_data.primitives.state.all_non_empty_in_list(input_list: list[Any]) list[Any]¶
Returns a list of all non-empty values from the input list.
Args: input_list (List[Any]): A list of items to check for emptiness.
Returns: List: A list of non-empty values.
- extended_data.primitives.state.all_non_empty_in_dict(input_dict: dict[Any, Any]) dict[Any, Any]¶
Returns a dictionary of all non-empty values from the input dictionary.
Args: input_dict (Dict[Any, Any]): A dictionary of items to check for emptiness.
Returns: Dict: A dictionary of non-empty values.
- extended_data.primitives.state.first_non_empty(*vals: Any) Any¶
Returns the first non-empty value.
Args: vals (Any): The values to check.
Returns: Any: The first non-empty value, or None if all are ‘nothing’.
- extended_data.primitives.state.any_non_empty(m: dict[Any, Any], *keys: Any) dict[Any, Any]¶
Returns the first non-empty value from a mapping for the given keys.
Args: m (Dict): The mapping to check. keys (Any): The keys to check.
Returns: Dict[Any, Any]: A mapping containing the first non-empty value.
- extended_data.primitives.state.yield_non_empty(m: dict[Any, Any], *keys: Any) collections.abc.Generator[dict[Any, Any], None, None]¶
Yields non-empty values from a mapping for the given keys.
Args: m (Dict): The mapping to check. keys (Any): The keys to check.
Yields: Generator[Dict[Any, Any], None, None]: A generator yielding non-empty values.