bpack.utils module
Internal utility functions and classes.
- bpack.utils.add_function_to_class(cls, name, args, body, *, globals=None, locals=None, return_type=<dataclasses._MISSING_TYPE object>, is_classmethod: bool = False)[source]
Create a function object and add it to the specified class.
- bpack.utils.classdecorator(func)[source]
Class decorator that can be used with or without parameters.
- bpack.utils.effective_type(type_: type | type[Enum], keep_annotations: bool = False) type[source]
Return the effective type.
In case of enums or sequences return the item type.
- bpack.utils.enum_item_type(enum_cls: type[Enum]) type[source]
Return the type of the items of an enum.Enum.
This function also checks that all items of an enum have the same (or compatible) type.
- bpack.utils.is_sequence_type(type_: type, error: bool = False) bool[source]
Return True if the input is an homogeneous typed sequence.
Please note that fields annotated with
typing.Tupleare not considered homogeneous sequences even if all items are specified to have the same type.
- bpack.utils.sequence_type(type_: type, error: bool = False) type | None[source]
Return the sequence type associated to a typed sequence.
The function return
listortupleif the input is considered a valid typed sequence,Noneotherwise.Please note that fields annotated with
typing.Tupleare not considered homogeneous sequences even if all items are specified to have the same type.