omnipy.components.general.models
| CLASS | DESCRIPTION |
|---|---|
Chain2 |
|
Chain3 |
|
Chain4 |
|
Chain5 |
|
Chain6 |
|
GroupByTypeModel |
Group list items by their runtime type. |
HasOuterType |
|
NotIterableExceptStrOrBytesModel |
Model describing any object that is not iterable, except for |
Chain2
Chain3
Bases: _ChainMixin, Model[_W | TypeVarStore1[_V] | _U], Generic[_U, _V, _W]
Source code in src/omnipy/components/general/models.py
Chain4
Bases: _ChainMixin, Model[_X | TypeVarStore2[_W] | TypeVarStore1[_V] | _U], Generic[_U, _V, _W, _X]
Source code in src/omnipy/components/general/models.py
Chain5
Bases: _ChainMixin, Model[_Y | TypeVarStore3[_X] | TypeVarStore2[_W] | TypeVarStore1[_V] | _U], Generic[_U, _V, _W, _X, _Y]
Source code in src/omnipy/components/general/models.py
Chain6
Bases: _ChainMixin, Model[_Z | TypeVarStore4[_Y] | TypeVarStore3[_X] | TypeVarStore2[_W] | TypeVarStore1[_V] | _U], Generic[_U, _V, _W, _X, _Y, _Z]
Source code in src/omnipy/components/general/models.py
GroupByTypeModel
Bases: Chain2[Model[list], Model[dict[type | GenericAlias, list]]]
Group list items by their runtime type.
The model converts a list into a dictionary mapping each inferred item type to the sublist of items having that type. For mappings and other non-string iterables, it attempts to preserve more detailed generic type information, such as key/value types for mappings and element types for tuples and other iterables, when those type forms can be constructed at runtime.
Examples:
>>> GroupByTypeModel([1, 'a', 2, [3], ['b']]).to_data()
{int: [1, 2], str: ['a'], list[int]: [[3]], list[str]: [['b']]}
Source code in src/omnipy/components/general/models.py
HasOuterType
Bases: Protocol
| METHOD | DESCRIPTION |
|---|---|
outer_type |
|
Source code in src/omnipy/components/general/models.py
NotIterableExceptStrOrBytesModel
Bases: Model[object | None]
Model describing any object that is not iterable, except for str and bytes types.
As strings and bytes are iterable (over the characters/bytes) but also generally useful and
often considered singular (or scalar) types, they are specifically allowed by this model.
Examples:
>>> from omnipy import NotIterableExceptStrOrBytesModel, print_exception
>>>
>>> NotIterableExceptStrOrBytesModel(1234)
NotIterableExceptStrOrBytesModel(1234)
>>> NotIterableExceptStrOrBytesModel('1234')
NotIterableExceptStrOrBytesModel(1234)
>>> with print_exception:
... NotIterableExceptStrOrBytesModel((1, 2, 3, 4))
ValidationError: 1 validation error for NotIterableExceptStrOrBytesModel
Note
JsonScalarModel is a strict submodel of NotIterableExceptStrOrBytesModel in that all objects allowed by JsonScalarModel are also allowed by NotIterableExceptStrOrBytesModel.