skeydula.server.config.env module

Loading environmental variables.

class skeydula.server.config.env.Missing

Bases: object

Class for generating singletons to test for if a field is missing.

skeydula.server.config.env.MISSING = Missing

Singleton to indicate an environment variable was missing.

class skeydula.server.config.env.EnvVarSpec

Bases: object

key: str
type: type
required: bool
__init__(key, type, required=True)

Method generated by attrs for class EnvVarSpec.

Parameters:
Return type:

None

skeydula.server.config.env.SUPPORTED_CAST_TYPES = (<class 'int'>, <class 'float'>, <class 'str'>, <class 'bool'>, <class 'NoneType'>)

The types supported for casting of environment variables.

class skeydula.server.config.env.EnvVarValue

Bases: object

spec: EnvVarSpec
raw: str | skeydula.server.config.env.Missing
value: Any
static do_cast(value, cast_type)

Decode an environment variable to a python type, uses json.loads.

Parameters:
Return type:

int | float | str | bool | None

classmethod from_raw(spec, raw)
Parameters:
Return type:

EnvVarValue

__init__(spec, raw, value)

Method generated by attrs for class EnvVarValue.

Parameters:
Return type:

None

class skeydula.server.config.env.EnvConfig

Bases: object

__init__(env_var_values)
Parameters:

env_var_values (tuple[skeydula.server.config.env.EnvVarValue, ...]) –

static validate_values(env_var_values)
Parameters:

env_var_values (tuple[skeydula.server.config.env.EnvVarValue, ...]) –

Return type:

bool

get(key)
Parameters:

key (str) –

Return type:

Any

skeydula.server.config.env.validate_environment(environment_variables, expected_specs)

Validate and cast a set of environment variables against a set of expected variables.

Parameters:
Return type:

EnvConfig

skeydula.server.config.env.extract_starlette_config(starlette_config, expected_specs)

Extract the starlette environment configuration for the expected environment variables.

If a variable is not found it will be set to None.

Parameters:
Return type:

dict[str, str | skeydula.server.config.env.Missing]