.. _jgdv.mixins.annotate.aliaser: ============================ jgdv.mixins.annotate.aliaser ============================ .. py:module:: jgdv.mixins.annotate.aliaser Type Aliases ------------ .. autoapisummary:: jgdv.mixins.annotate.aliaser.AliasAnnotation Classes ------- .. autoapisummary:: jgdv.mixins.annotate.aliaser.SubAlias_m Module Contents =============== .. py:data:: AliasAnnotation :type: TypeAlias :value: type | str | enum.Enum | Literal[False] | Literal[True] | tuple[AliasAnnotation, ...] .. _jgdv.mixins.annotate.aliaser.SubAlias_m: .. py:class:: SubAlias_m A Mixin to manage generics that resolve to specific registered subclasses. On class declaration, recognizes kwargs: - fresh_registry:bool : use a separate registry for this class and subclasses - accumulate:bool : annotations accumulate from their parent class - strict:bool : error if a subclass tries to overwrite a registration - default:bool : set this subclass as the default if no marks are specified when creating an instance - annotation:Maybe[str|type|enum|tuple[...]] : the key to use for this subclass, if class_getitem hasn't been used - no_register:bool : create the class, but don't register it cls[val] -> GenericAlias(cls, val) then: class RealSub(cls[val]) ... after which: cls[val] is RealSub Annotation Keys are stored in cls.__annotation__, under the cls._annotate_to key name. .. py:method:: _build_annotation(annotate) -> :classmethod: single point of truth for determining annotations from a cls and provided annotation .. py:method:: _clear_registry() -> :classmethod: .. py:method:: _retrieve_subtype(key) -> :classmethod: .. py:method:: cls_annotation() -> :classmethod: .. py:attribute:: _accumulator :type: ClassVar[bool] :value: False .. py:attribute:: _annotate_to :type: ClassVar[str] :value: '__jgdv_typevar__' .. py:attribute:: _default_k :type: ClassVar[str] :value: '__default__' .. py:attribute:: _registry :type: ClassVar[dict[AliasAnnotation, type]] .. py:attribute:: _strict :type: ClassVar[bool] :value: False