snowmobile.core.cfg.base

pydantic Config and Base class for snowmobile.toml and snowmobile-ext.toml objects.

Module Contents

Classes

Config

Configuration class for object model.

Base

Base class for object model parsed from snowmobile.toml.

class snowmobile.core.cfg.base.Config

Configuration class for object model.

extra
allow_population_by_field_name = True
allow_population_by_alias = True
arbitrary_types_allowed = True
json_encoders
apply_map_by_type(self, attrs: Dict, typ: Any, func: Callable)

Recursively apply function to all items of a dictionary of type ‘typ’.

Parameters
  • attrs (dict) – Dictionary to traverse.

  • typ (Type) – Type of object to apply function to.

  • func (Callable) – Function to apply to values of type typ.

Returns

Altered dictionary with function applied to all keys and values matching typ.

serialize(self, as_dict: Dict)Dict

Recursively applies json_encoder functions to all items of a dictionary.

class snowmobile.core.cfg.base.Base

Bases: pydantic.BaseModel, snowmobile.core.cfg.base.Config

Base class for object model parsed from snowmobile.toml.

property configured_args(self)Dict

Placeholder for configuration arguments of derived classes.

kwarg(self, arg_nm: str, arg_val: Any, arg_typ: Any)Any

Compares a provided keyword argument to a configured keyword argument.

from_relative(self, obj: Any)

Updates current object’s attributes with those from a different instance of the same class.

from_dict(self, args: Dict)

Accept a dictionary of arguments and updates the current object as if it were instantiated with those arguments.

as_serializable(self, by_alias: bool = False)

Returns a dictionary in serializable form.

json(self, by_alias: bool = False, **kwargs)str

API-facing json serialization method.