adorn.alter.alter module

Base Class for altering a config during type checking or object creation

class adorn.alter.alter.Alter

Bases: object

Base class that enables a config to be altered during type checking or object creation

a_contains(target_cls, orchestrator, obj)

Check if the application of an Alter is required

Parameters
  • target_cls (Type) – the target Type, the given obj will be converted into or checked against

  • orchestrator (Orchestrator) – container of all types, typically used to recurse down nested types

  • obj (Any) – an instance, that will be checked to see if it can be converted into the target_cls or will be converted to an instance of target_cls

Raises

NotImplementedError – This method must be overriden by a subclass

Return type

bool

a_get(target_cls, orchestrator, obj)

Capture the Alter associated with the arguments

Parameters
  • target_cls (Type) – the target Type, the given obj will be converted into or checked against

  • orchestrator (Orchestrator) – container of all types, typically used to recurse down nested types

  • obj (Any) – an instance, that will be checked to see if it can be converted into the target_cls or will be converted to an instance of target_cls

Raises

NotImplementedError – This method must be overriden by a subclass

Return type

Optional[Alter]

alter_obj(target_cls, orchestrator, obj)

Apply an alteration to an object

Parameters
  • target_cls (Type) – the target Type, the given obj will be converted into or checked against

  • orchestrator (Orchestrator) – container of all types, typically used to recurse down nested types

  • obj (Any) – an instance, that will be checked to see if it can be converted into the target_cls or will be converted to an instance of target_cls

Raises

NotImplementedError – This method must be overriden by a subclass

Return type

Union[Any, adorn.exception.type_check_error.TypeCheckError]

log_instance(target_cls, orchestrator, obj, instance)

Apply logging to an instantiate object

Parameters
  • target_cls (Type) – the target Type, the given obj was converted into

  • orchestrator (Orchestrator) – container of all types, typically used to recurse down nested types

  • obj (Any) – an instance, that was converted to an instance of target_cls

  • instance (Any) – the output of converting obj into an instance of target_cls

Raises

NotImplementedError – This method must be overriden by a subclass

Return type

None