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
.envfiles (usingpython-dotenv). - Load environment variables from YAML files (e.g.,
.env.ymlor custom path viaYAML_CONFIG_FILEenvironment 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]
Metadata
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)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bc_configs-0.4.1.tar.gz | 286.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|
Security for bc-configs 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.