You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Replace custom type aliases from the `toolbox_python.collection_types` module with standard library types like `list[str]`, `Collection[Any]`, and `Dict[Any, Any]`.
- Simplify `is_value_of_type()` and `assert_value_of_type()` function overloads by using `Collection[type]` to handle multiple input sequences.
- Relocate the `log_levels` type literal to `output.py` module to better align with its usage in output formatting.
- Add explicit `Callable` type hints to function aliases within the `checkers.py` module for improved type clarity.
- Update the `Defaults()` class docstring to include a dedicated methods section documenting the `.get()` method.
- Refactor the `flatten()` function and the `list_columns()` function to use standard collection types and remove redundant `@overload` definitions.
- Improve type checking logic in the `checkers.py` module to handle generic collections of types more robustly.
When we create and use Python variables, it is sometimes handy to add a default value for that variable.
78
77
This class will handle that process.
79
78
79
+
Methods:
80
+
- get(): From the value that is parsed in to the `value` parameter, convert it to `default` if `value` is `#!py None`, and convert it to `cast` if `cast` is not `#!py None`.
81
+
- _validate_value_and_default(): Validate to ensure that `value` and `default` are not both `#!py None`.
82
+
- _validate_type(): Check to ensure that `check_type` is a valid Python type
83
+
80
84
???+ example "Examples"
81
85
82
86
```pycon {.py .python linenums="1" title="Set up data for examples"}
This process is simple enough if the `values` are atomic types, like `#!py str`, `#!py int`, or `#!py float` types. But it is a little more tricky when the `values` are more complex types, like `#!py list` or `#!py dict`; here we need to use some recursion.
73
71
74
72
Params:
75
-
dictionary (dict_any):
73
+
dictionary (Dict[Any, Any]):
76
74
The input `#!py dict` that you'd like to have the `keys` and `values` switched.
When there are duplicate `values` being coerced to `keys` in the new dictionary. Raised because a Python `#!py dict` cannot have duplicate keys of the same value.
!!! observation "Here, the process would be to run a recursive process when it recognises that any `value` is a `#!py dict` object. So long as there are no duplicate values in any of the contained `#!py dict`'s, the resulting output will be a big, flat dictionary."
If any of the inputs parsed to the parameters of this function are not the correct type. Uses the [`@typeguard.typechecked`](https://typeguard.readthedocs.io/en/stable/api.html#typeguard.typechecked) decorator.
218
212
219
213
Returns:
220
-
(any_list):
214
+
(list[Any]):
221
215
The input having been coerced to a single flat `#!py list`.
0 commit comments