:py:mod:`alhambra.classes`
==========================

.. py:module:: alhambra.classes


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   alhambra.classes.IdentMergeableItem
   alhambra.classes.UpdateListD
   alhambra.classes.Serializable




Attributes
~~~~~~~~~~

.. autoapisummary::

   alhambra.classes.T_NMI
   alhambra.classes.T
   alhambra.classes.TS


.. py:data:: T_NMI

   

.. py:class:: IdentMergeableItem


   Bases: :py:obj:`Protocol`

   Base class for protocol classes.

   Protocol classes are defined as::

       class Proto(Protocol):
           def meth(self) -> int:
               ...

   Such classes are primarily used with static type checkers that recognize
   structural subtyping (static duck-typing), for example::

       class C:
           def meth(self) -> int:
               return 0

       def func(x: Proto) -> int:
           return x.meth()

       func(C())  # Passes static type check

   See PEP 544 for details. Protocol classes decorated with
   @typing.runtime_checkable act as simple-minded runtime protocols that check
   only the presence of given attributes, ignoring their type signatures.
   Protocol classes can be generic, they are defined as::

       class GenProto(Protocol[T]):
           def meth(self) -> T:
               ...

   .. py:method:: ident() -> str


   .. py:method:: merge(other: T_NMI) -> T_NMI


   .. py:method:: copy() -> T_NMI



.. py:data:: T

   

.. py:class:: UpdateListD(initial: Iterable[T_NMI] = tuple())


   Bases: :py:obj:`Generic`\ [\ :py:obj:`T_NMI`\ ]

   Abstract base class for generic types.

   A generic type is typically declared by inheriting from
   this class parameterized with one or more type variables.
   For example, a generic mapping type might be defined as::

     class Mapping(Generic[KT, VT]):
         def __getitem__(self, key: KT) -> VT:
             ...
         # Etc.

   This class can then be used as follows::

     def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
         try:
             return mapping[key]
         except KeyError:
             return default

   .. py:attribute:: data
      :type: dict[str, T_NMI]

      

   .. py:attribute:: __slots__
      :value: ('data',)

      

   .. py:method:: __setitem__(k: str, v: T_NMI)


   .. py:method:: __contains__(kv: str) -> bool


   .. py:method:: __getitem__(k: str | SupportsIndex) -> T_NMI
                  __getitem__(k: slice) -> T


   .. py:method:: __delitem__(k: str)


   .. py:method:: __len__()


   .. py:method:: refreshnames()


   .. py:method:: add(v: T_NMI)


   .. py:method:: __iter__()


   .. py:method:: __str__() -> str

      Return str(self).


   .. py:method:: __repr__() -> str

      Return repr(self).


   .. py:method:: update(d: Iterable[T_NMI])


   .. py:method:: aslist() -> list[T_NMI]


   .. py:method:: asdict() -> dict[str, T_NMI]


   .. py:method:: copy() -> T


   .. py:method:: __add__(other: Iterable[T_NMI]) -> T


   .. py:method:: __iadd__(other: Iterable[T_NMI]) -> T


   .. py:method:: __or__(other: Iterable[T_NMI]) -> T


   .. py:method:: __ior__(other: Iterable[T_NMI]) -> T


   .. py:method:: __sub__(other: Iterable[T_NMI]) -> T


   .. py:method:: search(regex: str, match: Literal[False] = False) -> T
                  search(regex: str, match: Literal[True]) -> list[tuple[re.Match, T_NMI]]



.. py:data:: TS

   

.. py:class:: Serializable


   Bases: :py:obj:`abc.ABC`

   Helper class that provides a standard way to create an ABC using
   inheritance.

   .. py:method:: _deserialize(input: Any) -> TS
      :classmethod:
      :abstractmethod:


   .. py:method:: _serialize() -> Any
      :abstractmethod:


   .. py:method:: from_yaml(*args, **kwargs) -> TS
      :classmethod:


   .. py:method:: from_toml(*args, **kwargs) -> TS
      :classmethod:


   .. py:method:: from_json(*args, **kwargs) -> TS
      :classmethod:


   .. py:method:: to_yaml(*args, **kwargs)


   .. py:method:: to_json(*args, **kwargs)


   .. py:method:: to_toml(*args, **kwargs)



