Module reahl.component.config

Classes in this module manage system configuration.

Each Reahl component can have its own config file. The config files of all components used by an application are stored in a common directory. If the config file for a component is missing, defaults are assumed.

Config files are Python code. Inside a config file, an instance of the component’s Configuration is bound to a variable name.


class reahl.component.config.StoredConfiguration(config_directory_name, strict_checking=False)

Bases: Configuration

The Configuration of a whole set of components, stored together in a directory.

configure(validate=True, include_test_dependencies=[])

Read and optionally validate the configuration.


validate – If True (the default), also check that all required config is specified and warns about dangerous defaults.


class reahl.component.config.Configuration

Bases: object

A collection of ConfigSettings for a component. To supply configuration for your component, subclass from this class and assign each wanted ConfigSetting as a class attribute. Assign the required filename and config_key class attributes in your subclass as well. The resultant class should also be listed in the configuration key of the [tool.reahl-component] table in your pyproject.toml.

filename = None

The name of the config file from which this Configuration will be read.

config_key = None

The variable name to which an instance of this Configuration will be bound when reading filename


class reahl.component.config.ConfigSetting(default=<class 'reahl.component.config.ExplicitSettingRequired'>, description='No description supplied', dangerous=False, automatic=False)

Bases: object

Used to define one configuration setting on a Configuration.

  • default – The default value to be used if not specified in a config file.

  • description – A user readable description explaining what this ConfigSetting is for.

  • dangerous – Set this to True, if a warning should be emitted when used with the supplied default value.

  • automatic – Set this to True for a ConfigSetting which is meant to be used for dependency injection.


class reahl.component.config.DeferredDefault(getter)

Bases: object

Sometimes the default value for a ConfigSetting cannot be set when the Configuration is declared. An instance of DeferredDefault can be passed as default in such a scenario.

DeferredDefault wraps a callable, which will be called only once the config value is read. The callable is passed a single argument: the Configuration on which this ConfigSetting is defined.


class reahl.component.config.EntryPointClassList(name, description='Description not supplied')

Bases: ConfigSetting

A ConfigSetting which is not set by a user at all – rather, its value (a list of classes or other importable Python objects) is read from the entry point named name.

  • name – The name of the entry point to read.

  • description – (See ConfigSetting)