Skip to content

Usage

Create

Import ABConfig and create a your config class:

1
2
3
4
5
from abconfig import ABConfig

class MyConfig(ABConfig):
   host = str
   port = int

Get instance:

1
2
3
config = MyConfig()
config
{'host': None, 'port': None}

or you can set default values:

1
2
3
4
5
6
7
class MyConfig(ABConfig):
   host = '127.0.0.1'
   port = 8000

config = MyConfig()
config
{'host': '127.0.0.1', 'port': 8000}

It's Dict

config is a python dict-like instance:

1
2
3
4
5
6
config['host']
None
config.get('port', 8000)
8000
config.items()
ItemsView({'host': None, 'port': None})

and by attrs:

1
2
config.host
None

Supported sources


Multiple sources

You can define multiple sources, their values ​​will be use by priority:

  1. Default;
  2. File;
  3. Environment;
  4. Vault.

Common settings

Default values:

  • __hidesettings__ - hide ABConfig settings from result;
  • __hidesettings_exclude__ - list of settings that need to be shown anyway.
1
2
3
class MyConfig(ABConfig):
    __hidesettings__ = True
    __hidesettings_exclude__ = []