Skip to content

Define models

Maturity labels

  • Now: Stable and supported in current releases.
  • Preview: Usable today, but behavior and APIs may evolve.
  • Planned: Not yet implemented.

Note

Status: Now

Quick patterns

Pattern 1: Model[T] directly

>>> import omnipy as om
>>> om.Model[list[int]]((1, '2', 3.0))

Pattern 2: subclass for reusable names

>>> import omnipy as om
>>> class IntList(om.Model[list[int]]):
...     ...
>>> IntList(['1', 2, 3.0])

Pattern 3: nested type parameters

>>> import omnipy as om
>>> om.Model[dict[str, list[int]]]({'a': [1, '2'], 'b': [3.0]})