Skip to main content

bc-config

Make configuring your application easier.

Installing

pip install bc-configs

Make your custom config class

import os
from bc_configs import BaseConfig, define

define()

class MyConfig(BaseConfig):
    some_int: int
    some_string: str
    some_bool: bool

my_config = MyConfig()  # type: ignore[call-arg]

assert int(os.getenv("MY_SOME_INT")) == my_config.some_int  # True
assert os.getenv("MY_SOME_STRING") == my_config.some_string  # True
assert bool(os.getenv("MY_SOME_BOOL")) == my_config.some_bool  # True

The name of the environment variable is formed based on the names of the class and field.

Features

  • Load environment variables from .env files (using python-dotenv).
  • Load environment variables from YAML files (e.g., .env.yml or custom path via YAML_CONFIG_FILE environment variable).
  • Load secrets from HashiCorp Vault (using hvac).

Error handling

When a required configuration field is missing, the library raises a ValidationError with an enriched error message that includes the environment variable name:

ValidationError: 1 validation error for MyConfig
some_int
  Field required  →  env var: 'MY_SOME_INT' (description: Database port number) [type=missing, input_value={}, input_type=dict]

If the field has a description, it will be included in the error message:

class MyConfig(BaseConfig):
    some_int: int = Field(description="Database port number")

Error message:

ValidationError: 1 validation error for MyConfig
some_int
  Field required  →  env var: 'MY_SOME_INT' [type=missing, input_value={}, input_type=dict]

Release files for bc-configs 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bc-configs 0.4.1
File Size Uploaded
bc_configs-0.4.1.tar.gz 286.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bc-configs 0.4.1
File Interpreter ABI Platform
bc_configs-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 296.7 kB

Release files / bc_configs-0.4.1.tar.gz

Download URL bc_configs-0.4.1.tar.gz
Size 286.9 kB
Tags Source
SHA-256 checksum
How to use checksums
49c37dc6e8fb7e4a245a56735f6c56909d05093e7aa5910ff884cc0d726052a3
BLAKE2b-256 checksum
How to use checksums
807e4029072e09d161794ec8ef8f5ac75f1ac12d586412b03d2eeea40d039a4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.2

Release files / bc_configs-0.4.1-py3-none-any.whl

Download URL bc_configs-0.4.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94fee499efcad29d8a96bc300a3b6451b67653051e34089616c2aea955dfd8b1
BLAKE2b-256 checksum
How to use checksums
06cfc0e79376909fa19a417fbe44585b6717eec57a6a3b5ae9b2efe21747e0a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.2

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page