nucleus.pydantic_base

NOTE: We started using pydantic during v1 and are kind of stuck with it now unless we write a compatibility layers. As a library we want to support v1 and v2 such that we’re not causing downstream problems for our users. This means we have to do some import shenanigans to support both v1 and v2.

DictCompatibleImmutableModel

Backwards compatible wrapper where we transform dictionaries into Pydantic Models

DictCompatibleModel

Backwards compatible wrapper where we transform dictionaries into Pydantic Models

ImmutableModel

Mixin to provide __str__, __repr__, and __pretty__ methods. See #884 for more details.

class nucleus.pydantic_base.DictCompatibleImmutableModel(**data)

Backwards compatible wrapper where we transform dictionaries into Pydantic Models

Allows us to access model.key with model[“key”].

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Parameters:

data (Any)

class nucleus.pydantic_base.DictCompatibleModel(**data)

Backwards compatible wrapper where we transform dictionaries into Pydantic Models

Allows us to access model.key with model[“key”].

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Parameters:

data (Any)

class nucleus.pydantic_base.ImmutableModel(**data)

Mixin to provide __str__, __repr__, and __pretty__ methods. See #884 for more details.

__pretty__ is used by [devtools](https://python-devtools.helpmanual.io/) to provide human readable representations of objects.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Parameters:

data (Any)