penvΒΆ
- pconfigs.penv(_cls=None, *, convention=None)[source]ΒΆ
Decorator that creates a config that accesses environment variables.
See also
For examples, see Environments
The decorator can be used with or without arguments:
@penvor@penv(): Use the attribute name as the environment variable name.@penv(convention="uppercase"): Convert attribute names to uppercase when deriving environment variable names (for example,my_flagβMY_FLAG).@penv(convention=callable): Use a custom callableconvention(name: str) -> strto transform attribute names into environment variable names.
- Parameters:
convention (Convention | ConventionTransform, optional) β Name transformation strategy for environment variable names. May be the string
"uppercase"or a callable(str) -> str. If omitted, attribute names are used as is.- Returns:
A new class derived from
EnvironmentBaseand usingEnvironmentMetaclass, with annotated attributes replaced byEnvVardescriptors.- Return type:
Type- Raises:
ValueError β If an unsupported string convention is provided.