Visibility

Confident provides built-in functions to show details about the object after creation. The details can be logged/printed and provide clarity about the source of every value in the object.

Multiple Sources Recognition

In order to monitor which fields were loaded from what source, full_details() can be used. Notice the difference between the source types:

 1import os
 2from typing import List
 3
 4from confident import Confident
 5
 6class AppConfig(Confident):
 7    title: str = 'my_application'
 8    timeout: int
 9    input_paths: List[str]
10
11os.environ['input_paths'] = '["/tmp/input_a", "/tmp/input_b"]'
12
13config = AppConfig(files='config.yaml')
14
15print(config.full_details())
16#> {
17# 'title': ConfigProperty(name='title', value='my_application', origin_value='my_application', source_name='AppConfig', source_type='class_default', source_location=WindowsPath('example.py')),
18# 'timeout': ConfigProperty(name='timeout', value=60, origin_value=60, source_name='config.yaml', source_type='file', source_location=WindowsPath('config.yaml')),
19# 'input_paths': ConfigProperty(name='input_paths', value=['/tmp/input_a', '/tmp/input_b'], origin_value='["/tmp/input_a", "/tmp/input_b"]', source_name='input_paths', source_type='env_var', source_location='input_paths'),
20# }

Confident Object Creation location

The position of the the Confident object declaration:

config.specs().class_path
#> PosixPath('~/MyProject/project_config.py')

The position of the the Confident object instance creation:

config.specs().creation_path
#> PosixPath('~/MyProject/main.py')