bagof.factories.common
Common factories (none, union, literal, typevar, annotated).
Classes
NoneFactory
UnionFactory
Factory for Union hints.
Returns None if the union is optional, otherwise builds a value for
the first member type that can be instantiated.
Example
Methods:
LiteralFactory
TypeVarFactory
Factory for TypeVar hints.
Builds a value for the type the typevar resolves to (its default, bound or constraints). A typevar with none of the three stands for any type at all, so there is nothing to build and this raises.
Methods:
AnnotatedFactory
Factory for Annotated hints.
Builds a value using the annotated origin type, unless a more specific factory is provided in the annotation metadata.
Attributes
factories
property
factories: tuple[Factory, ...]
The factories that apply to this annotated hint, ordered from
the origin type (least specific) to the last matching metadata
entry (most specific, used first by __call__).
Methods:
register_metadata
classmethod
Register a factory class for one or more pieces of annotation metadata.
Distinct from Factory.register, which registers a factory
for a type hint in the global registry; this one registers it
for a piece of Annotated metadata.