cornflakes.decorator.config

cornflakes.decorator.config(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, kw_only=False, slots=False, match_args=True, dict_factory=None, tuple_factory=None, value_factory=None, alias_generator=None, eval_env=False, validate=False, updatable=False, ignore_none=False, files=None, sections=None, use_regex=False, is_list=False, default_loader=None, allow_empty=False, chain_configs=False, init_default_config=True, **kwargs)

Config decorator to parse INI files and implement config loader methods to config-classes.

Parameter:
  • alias_generator (Callable[[str], str] | None) –

  • ignore_none (bool) –

  • value_factory (Callable | None) –

  • init_default_config (bool, optional) –

  • match_args (bool) –

  • slots (bool) –

  • kw_only (bool) –

  • cls (class) – The class type to create the config dataclass from.

  • init (bool, optional) – Whether to automatically add an __init__ method to the class. Default is True.

  • repr (bool, optional) – Whether to automatically add a __repr__ method to the class. Default is True.

  • eq (bool, optional) – Whether to automatically add an __eq__ method to the class. Default is True.

  • order (bool, optional) – Whether to automatically add comparison methods (__lt__, __le__, __gt__, __ge__) to the class. Default is False.

  • unsafe_hash (bool, optional) – Whether to add a __hash__ method to the class. Default is False.

  • frozen (bool, optional) – Whether to make the generated class immutable. Default is False.

  • dict_factory (Callable, optional) – A function that returns a dict-like object which will be used as the base of the dataclass object. Default is None.

  • tuple_factory (Callable, optional) – A function that returns a tuple-like object which will be used as the base of the dataclass object. Default is None.

  • eval_env (bool, optional) – If set to True, will evaluate environment variables in the config file. Default is False.

  • validate (bool, optional) – If set to True, will validate the config file upon loading. Default is False.

  • updatable (bool, optional) – If set to True, the config object can be updated after it’s created. Default is False.

  • files (Union[List[str], str], optional) – A list or a single string of file path(s) to the default config files.

  • sections (Union[List[str], str], optional) – A list or a single string of section name(s) in the config file(s).

  • use_regex (bool, optional) – If set to True, will evaluate all sections in the config file(s) by regex. Default is False.

  • is_list (Union[bool, int], optional) – If set to True or a positive integer, will load the Config as a list of config class objects. Default is False.

  • default_loader (Loader, optional) – The default config parser method.

  • allow_empty (bool, optional) – If set to True, an empty config result will be allowed. Default is False.

  • chain_configs (bool, optional) – If set to True, multiple config files will be chained into a single config. Default is False.

  • init_default_config – If set to True, will initialize the default config file(s) upon loading. Default is True.

  • kwargs (Any) –

Rückgabe:

If a class is given as config_cls, a new decorated class is returned. If no class is given, the decorator itself is returned with the custom default arguments.

Rückgabetyp:

Union[Type[Config], Type[ConfigGroup], Type[_T]], Callable[…, Union[Type[Config], Type[ConfigGroup], Type[_T]]]