get_var(name, default=Ellipsis, cast=<class 'str'>)

Retrieve an environment variable, and raise if it’s undefined and no default was passed.

Parameters:
  • name (str) – The name of the environment variable.

  • default (Union[TypeVar(T), Any]) – The default value to return if the environment variable is not defined. If nothing is passed, undefined variables raise an exception.

  • cast (Callable[[str], TypeVar(T)]) – A function to cast the value to a specific type. Default is str.

Raises:

RuntimeError – If the environment variable is not defined and no default was provided.

Return type:

TypeVar(T)

Returns:

The value of the environment variable cast to type by the specified function.