backend.config
Creates the spock config interface that wraps attr
#
_base_attrdef _base_attr(cls, kw_only, make_init, dynamic)
Map type hints to katras
Connector function that maps type hinting style to the defined katra style which uses the more strict attr.ib() definition
Handles dynamic decorators which allows for inheritance of non @spock decorated classes
Arguments:
cls
- basic class defdynamic
- allows inherited classes to not be @spock decorated
Returns:
cls
- base spock classes derived from the MROattrs_dict
- the current dictionary of attr.attribute valuesmerged_annotations
- dictionary of type annotations
#
_process_classdef _process_class(cls, kw_only: bool, make_init: bool, dynamic: bool)
Process a given class
Arguments:
cls
- basic class definitionkw_only
- set kwarg onlymake_init
- make an init functiondynamic
- allows inherited classes to not be @spock decorated
Returns:
cls with attrs dunder methods added
#
spock_attrdef spock_attr(maybe_cls=None, kw_only=True, make_init=True, dynamic=False)
Map type hints to katras
Connector function that maps type hinting style to the defined katra style which uses the more strict attr.ib() definition -- this allows us to attach the correct validators for types before the attrs class is built
Arguments:
maybe_cls
- maybe a basic class def maybe None depending on call typekw_only
- Make all attributes keyword-onlymake_init
- bool, define a init() methoddynamic
- allows inherited classes to not be @spock decorated -- will automatically cast parent classes to a spock class by traversing the MRO
Returns:
cls
- attrs class that is frozen and kw only