pystencils.codegen.config.Option#
- class pystencils.codegen.config.Option(default=None, validator=None)#
Option descriptor.
This descriptor is used to model configuration options. It maintains a default value for the option that is used when no value was specified by the user.
In configuration options, the value
None
stands forunset
. It can therefore not be used to set an option to the meaning “not any”, or “empty” - for these, special values need to be used.The Option allows a validator function to be specified, which will be called to perform sanity checks on user-provided values.
Through the validator, options may also be set from arguments of a different type (
Arg_T
) than their value type (Option_T
). IfArg_T
is different fromOption_T
, the validator must perform the conversion from the former to the latter.Note
Arg_T
must always be a supertype ofOption_T
.- Parameters:
default (Option_T | None)
validator (Callable[[Any, Arg_T | None], Option_T | None] | None)