Base Parser

class django_docker_helpers.config.backends.base.BaseParser(scope=None, config=None, nested_delimiter='__', path_separator='.', env=None)[source]

Base class to inherit from in custom parsers.

All __init__ arguments MUST be optional if you need from_env() automatic parser initializer (it initializes parsers like parser_class(**parser_options)).

Since ConfigLoader can initialize parsers from environment variables it’s recommended to annotate argument types to provide a correct auto typecast.

BaseParser creates a logger with name __class__.__name__.

BaseParser implements generic copying of following arguments without any backend-specific logic inside.

  • scope (Optional[str]) – a global prefix to all underlying values

  • config (Optional[str]) – optional config

  • nested_delimiter (str) – optional delimiter for environment backend

  • path_separator (str) – specifies which character separates nested variables, default is '.'

  • env (Optional[Dict[str, str]]) – a dict with environment variables, default is os.environ

property client

Helper property to lazy initialize and cache client. Runs get_client().


an instance of backend-specific client

static coerce(val, coerce_type=None, coercer=None)[source]

Casts a type of val to coerce_type with coercer.

If coerce_type is bool and no coercer specified it uses coerce_str_to_bool() by default.

  • val (Any) – a value of any type

  • coerce_type (Optional[Type]) – any type

  • coercer (Optional[Callable]) – provide a callback that takes val and returns a value with desired type

Return type



type casted value

get(variable_path, default=None, coerce_type=None, coercer=None, **kwargs)[source]

Inherited method should take all specified arguments.

  • variable_path (str) – a delimiter-separated path to a nested value

  • default (Optional[Any]) – default value if there’s no object by specified path

  • coerce_type (Optional[Type]) – cast a type of a value to a specified one

  • coercer (Optional[Callable]) – perform a type casting with specified callback

  • kwargs – additional arguments inherited parser may need


value or default


If your backend needs a client, inherit this method and use client() shortcut.


an instance of backend-specific client