Skip to main content

Loading configurations from multiple sources into a data model.

Project description

Confident

PyPI - Python Version PyPI GitHub Actions Workflow Status GitHub Coverage

Documentation


Confident helps you create configuration objects from multiple sources such as files, environment variables and maps. Confident's BaseConfig class is a data model that enforces validation and type hints by using pydantic library.

With Confident you can manage multiple configurations depending on the environment your code is deployed in. While having lots of flexibility in how to describe your config objects, Confident will provide visibility of the process and help you expose misconfiguration as soon as possible.

Example

import os

from confident import BaseConfig


# Creating your own config class by inheriting from `BaseConfig`.
class MyAppConfig(BaseConfig):
    port: int = 5000
    host: str = 'localhost'
    labels: list


# Illustrates some environment variables.
os.environ['host'] = '127.0.0.1'
os.environ['labels'] = '["FOO", "BAR"]'  # JSON strings can be used for more types.

# Creating the config object. `BaseConfig` will load the values of the properties.
config = MyAppConfig()

print(config.host)
# > 127.0.0.1
print(config.model_dump_json())
# > {"port":5000,"host":"127.0.0.1","labels":["FOO","BAR"]}
print(config)
# > port=5000 host='127.0.0.1' labels=['FOO', 'BAR']
print(config.full_fields())
# > {
# 'port': ConfigField(name='port', value=5000, origin_value=5000, source_name='MyAppConfig', source_type='class_default', source_location=PosixPath('~/confident/readme_example.py')),
# 'host': ConfigField(name='host', value='127.0.0.1', origin_value='127.0.0.1', source_name='host', source_type='env_var', source_location='host'),
# 'labels': ConfigField(name='labels', value=['FOO', 'BAR'], origin_value='["FOO", "BAR"]', source_name='labels', source_type='env_var', source_location='labels')
# }

Installation

pip install confident

Capabilities

Customized Fields Loaders

Built-in loaders:

  • Environment variables.
  • Config files such as 'json' and 'yaml'.
  • Config maps to load fields depending on the environment. (See documentation)

It is possible to configure the loading priority and add your own loader classes.

Full Support of Pydantic BaseSettings

Confident core functionality is based on pydantic library. That means BaseConfig object has all the benefits of pydantic's BaseModel and BaseSettings including type validation, object serialization and many more features.

Config Loading Visibility

BaseConfig object stores details about the fields loading process and offers ways to understand the source of each loaded field. Details about the origin value (before conversion), the location of the source and the type of loader, can all be accessed from the object.

Examples

More examples can be found in the project's repository.

Contributing

To contribute to Confident, please make sure any new features or changes to existing functionality include test coverage.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

confident-2.0.0b1.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

confident-2.0.0b1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file confident-2.0.0b1.tar.gz.

File metadata

  • Download URL: confident-2.0.0b1.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for confident-2.0.0b1.tar.gz
Algorithm Hash digest
SHA256 e411b5e71e69450d560faf626ef66edf5a7fc0181f21a44e928ebf23340dfb9b
MD5 694ffe97082c84e62905e8be9928b519
BLAKE2b-256 01418cc675dc9c77ddaab035b517f700d7fd9c6d743f8a8c085780c7f5677be0

See more details on using hashes here.

File details

Details for the file confident-2.0.0b1-py3-none-any.whl.

File metadata

  • Download URL: confident-2.0.0b1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for confident-2.0.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 2fe987a3f326f18a5d6e2e3e85f3ff81633327957c2e74477ddb18db6c599297
MD5 e8490fbdfb003d74c24cb4808bbfe713
BLAKE2b-256 6ba4c90dab5adc621c9f6c761b6124db13758491497d5ee9145fef2e5fa48759

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page