RuleCheckAnyKw Class
- class kwhelp.decorator.RuleCheckAnyKw(arg_info: Dict[str, Union[int, kwhelp.rules.IRule, Iterable[kwhelp.rules.IRule]]], rules: Optional[Iterable[Union[kwhelp.rules.IRule, Iterable[kwhelp.rules.IRule]]]] = None, **kwargs)[source]
Bases:
kwhelp.decorator.RuleCheckAllKw
Decorator that decorates methods that require specific args to match rules specificed in
rules
list.If a function specific args do not match at least one matching rule in
rules
list then validation will fail.See also
- __init__(arg_info: Dict[str, Union[int, kwhelp.rules.IRule, Iterable[kwhelp.rules.IRule]]], rules: Optional[Iterable[Union[kwhelp.rules.IRule, Iterable[kwhelp.rules.IRule]]]] = None, **kwargs)
Constructor
- Parameters
arg_info (Dict[str, Union[int, IRule, Iterable[IRule]]]) – Dictionary of Key and int, IRule, or Iterable[IRule]. Each Key represents that name of an arg to check with one or more rules. If value is int then value is an index that corresponds to an item in
rules
.rules (Iterable[Union[IRule, Iterable[IRule]]], optional) – List of rules for arg_info entries to match. Default
None
- Keyword Arguments
raise_error (bool, optional) –
If
True
then an Exception will be raised if a validation fails. The kind of exception raised depends on the rule that is invalid. Typically aTypeError
or aValueError
is raised.If
False
then an attribute will be set on decorated function namedis_rules_kw_all_valid
indicating if validation status. DefaultTrue
.ftype (DecFuncType, optional) – Type of function that decorator is applied on. Default
DecFuncType.FUNCTION
opt_return (object, optional) – Return value when decorator is invalid. By default an error is rasied when validation fails. If
opt_return
is supplied then it will be return when validation fails and no error will be raised.opt_logger (Union[Logger, LoggerAdapter], optional) – Logger that logs exceptions when validation fails.
- property args: Iterable[object]
Gets/sets wrapped function args
- property fn_cache: Dict[str, object]
Gets function level cache
- property kwargs: Dict[str, Any]
Gets/sets wrapped function kwargs