Optional dependencies

These features intentionally stay outside of the core stereotype implementation as they may introduce dependencies.

Schematics adapter

Use this only if already depending on Schematics. If migrating from Schematics, be sure to check out the migration guide.

class stereotype.contrib.schematics.SchematicsModelField(*, default: Any = Missing, hide_none: bool = False, primitive_name: str | None = Missing, to_primitive_name: str | None = Missing)[source]

Bases: ModelField

Field containing a Schematics Model class, as specified in the annotation. Provides a way to combine stereotype and schematics models, e.g., for migrating from schematics in steps. Deep copy doesn’t work in Schematics 2, works in Schematics 1.

Parameters:
  • default (Any) – Means the field isn’t required, should be None or a callable, for example the model’s class

  • hide_none (bool) – If the field’s value is None, it will be hidden from serialized output

  • primitive_name (str | None) – Changes the key used to represent the field in serialized data - input or output

  • to_primitive_name (str | None) – Changes the key used to represent the field in serialized data - output only