configconfig.configvar
-
class
ConfigVar
(raw_config_vars: Dict[str, Any])[source] Base class for
YAML
configuration values.The class docstring should be the description of the config var, with an example, and the name of the class should be the variable name.
Alternatively, for a more Pythonic naming approach, the variable name can be set with the
name
class variable.Example:
class platforms(ConfigVar): """ A case-insensitive list of platforms to perform tests for. Example: .. code-block:: yaml platforms: - Windows - Linux These values determine the GitHub test workflows to enable, and the Trove classifiers used on PyPI. """ dtype = List[Literal["Windows", "macOS", "Linux"]] default: List[str] = ["Windows", "macOS", "Linux"] category: str = "packaging"
Attributes:
The category the
ConfigVar
is listed under in the documentation.The default value of the configuration value if it is optional.
The allowed type or types in the
YAML
configuration file.Flag to indicate whether the configuration value is required.
The variable type passed to Jinja2.
Methods:
get
([raw_config_vars])Returns the value of this
ConfigVar
.Returns the reStructuredText documentation for the
ConfigVar
.validate
([raw_config_vars])Validate the value obtained from the
YAML
file and coerce into the appropriate return type.validator
(value)Function to call to validate the values.
-
default
= '' Type:
Union
[Callable
[[Dict
[str
,Any
]],Any
],Any
]The default value of the configuration value if it is optional. Defaults to
''
if unset.May also be set to a callable which returns a dynamic or mutable default value.
-
classmethod
make_documentation
()[source] Returns the reStructuredText documentation for the
ConfigVar
.- Return type
-
required
= False Type:
bool
Flag to indicate whether the configuration value is required. Default
False
.
-
rtype
= typing.Any Type:
Type
The variable type passed to Jinja2. If
None
dtype
is used. Ignored fordtype=bool
.
-
classmethod
validate
(raw_config_vars=None)[source] Validate the value obtained from the
YAML
file and coerce into the appropriate return type.
-
classmethod
validator
(value)[source] Function to call to validate the values.
The callable must have a single required argument (the value).
Should raise
ValueError
if values are invalid, and return the values if they are valid.May change the values (e.g. make lowercase) before returning.
- Return type
-