# atom.meta package

## Submodules

Metaclass implementing atom members customization.

class atom.meta.atom_meta.AtomMeta(name: str, bases: Tuple[type, ...], dct: Dict[str, Any], enable_weakrefs: bool = False, use_annotations: bool = True, type_containers: int = 1)

  Bases: `type`

  The metaclass for classes derived from Atom.

  This metaclass computes the memory layout of the members in a given class so that the CAtom class can allocate exactly enough space for the object data slots when it instantiates an object.

  All classes deriving from Atom will be automatically slotted, which will prevent the creation of an instance dictionary and also the ability of an Atom to be weakly referenceable. If that behavior is required, then a subclasss should declare the appropriate slots.

exception atom.meta.atom_meta.MissingMemberWarning

  Bases: `UserWarning`

  Signal an expected member is not present.

atom.meta.atom_meta.add_member(cls: AtomMeta, name: str, member: Member) → None

  Add or override a member after the class creation.

atom.meta.atom_meta.clone_if_needed(cls: AtomMeta, member: M) → M

  Clone a member if is not owned by a class.

  This function is meant to be used in __init__subclass__ to safely customize members static behaviors.

atom.meta.annotation_utils.generate_member_from_type_or_generic(type_generic: Any, default: Any, annotate_type_containers: int) → Member

  Generate a member from a type or generic alias.

atom.meta.annotation_utils.generate_members_from_cls_namespace(cls_name: str, namespace: MutableMapping[str, Any], annotate_type_containers: int) → None

  Generate the member corresponding to a type annotation.

Custom marker objects used to modify the default settings of a member.

class atom.meta.member_modifiers.set_default(value: Any)

  Bases: `object`

  An object used to set the default value of a base class member.

  clone() → set_default

    Create a clone of the sentinel.

  name: str | None

    Name of the member for which a new default value should be set. Used by the metaclass.

  value: Any

    New default value to be set.

Tools to declare static observers in Atom subclasses

class atom.meta.observation.ExtendedObserver(funcname: str, attr: str)

  Bases: `object`

  A callable object used to implement extended observers.

  attr: str

    Attribute name on the target object which should be observed.

  funcname: str

    Name of the function on the owner object which should be used as the observer.

class atom.meta.observation.ObserveHandler(pairs: ~typing.List[~typing.Tuple[str, str | None]], change_types: ~atom.catom.ChangeType = <ChangeType.ANY: 255>)

  Bases: `object`

  An object used to temporarily store observe decorator state.

  change_types: ChangeType

    Types of changes to listen to.

  clone() → ObserveHandler

    Create a clone of the sentinel.

  func: Callable[[Mapping[str, Any]], None] | None

    Callable to be used as observer callback.

  funcname: str | None

    Name of the callable. Used by the metaclass.

  pairs: List[Tuple[str, str | None]]

    List of 2-tuples which stores the pair information for the observers.

atom.meta.observation.observe(*names: str, change_types: ~atom.catom.ChangeType = <ChangeType.ANY: 255>) → ObserveHandler

  A decorator which can be used to observe members on a class.

  Parameters:

    - *names – The str names of the attributes to observe on the object. These must be of the form ‘foo’ or ‘foo.bar’.

    - change_types – The flag specifying the type of changes to observe.