erc7730.model.base module

Base model for library, using pydantic.

See https://docs.pydantic.dev

class erc7730.model.base.Model[source]View on GitHub

Bases: BaseModel

Base model for library, using pydantic.

See https://docs.pydantic.dev

classmethod load(path: Path) Self[source]View on GitHub

Load a model from a JSON file.

Parameters:

path – file path

Returns:

validated in-memory representation of model

Raises:

Exception – if the file does not exist or has validation errors

classmethod load_or_none(path: Path) Self | None[source]View on GitHub

Load a model from a JSON file.

Parameters:

path – file path

Returns:

validated in-memory representation of descriptor, or None if file does not exist

Raises:

Exception – if the file has validation errors

model_config = {'allow_inf_nan': False, 'arbitrary_types_allowed': False, 'extra': 'forbid', 'frozen': True, 'strict': True, 'validate_assignment': True, 'validate_default': True, 'validate_return': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

save(path: Path) None[source]View on GitHub

Write a model to a JSON file, creating parent directories as needed.

to_json_string() str[source]View on GitHub

Serialize the model to a JSON string.

Returns:

JSON representation of model, serialized as a string