configconfig.utils

Utility functions.

Functions:

get_literal_values(literal)

Returns a tuple of permitted values for a typing.Literal.

optional_getter(raw_config_vars, cls, required)

Returns either the configuration value, the default, or raises an error if the value is required but wasn’t supplied.

get_yaml_type(type_)

Get the YAML type that corresponds to the given Python type.

make_schema(*configuration_variables)

Create a JSON schema from a list of ConfigVar classes.

check_union(obj, dtype)

Check if the type of obj is one of the types in a typing.Union, typing.List etc.

get_json_type(type_)

Get the type for the JSON schema that corresponds to the given Python type.

get_literal_values(literal)[source]

Returns a tuple of permitted values for a typing.Literal.

New in version 0.3.0.

Parameters:

literal (Literal[])

Return type:

Tuple[Any]

optional_getter(raw_config_vars, cls, required)[source]

Returns either the configuration value, the default, or raises an error if the value is required but wasn’t supplied.

Parameters:
Return type:

Any

get_yaml_type(type_)[source]

Get the YAML type that corresponds to the given Python type.

Parameters:

type_ (Type)

Return type:

str

make_schema(*configuration_variables)[source]

Create a JSON schema from a list of ConfigVar classes.

Parameters:

configuration_variables

Return type:

Dict[str, Any]

Returns:

Dictionary representation of the JSON schema.

check_union(obj, dtype)[source]

Check if the type of obj is one of the types in a typing.Union, typing.List etc.

Parameters:
Return type:

bool

get_json_type(type_)[source]

Get the type for the JSON schema that corresponds to the given Python type.

Parameters:

type_ (Type)

Return type:

Dict[str, Union[str, List, Dict]]