A useful Pydantic based config system with various options
Project description
Bear Config
A useful Pydantic based config system with various options
Installation
With uv: uv tool install bear-config
Configuration precedence
Values are merged in order; later sources override earlier ones:
default.toml{env}.toml(for the active environment, e.g.,dev.toml,prod.toml)local.toml- Environment variables prefixed with your program name (e.g.,
MY_APP_...)
Search paths (by default): ~/.config/{program}/ and ./config/{program}/.
Quickstart
Define a Pydantic model for your settings, then load it with the ConfigManager.
from pydantic import BaseModel
from bear_config.config_manager import ConfigManager
class Database(BaseModel):
host: str = "localhost"
port: int = 5432
class Settings(BaseModel):
database: Database = Database()
debug: bool = False
config = ConfigManager[Settings](
config_model=Settings,
program_name="my_app",
env="dev",
).config
print(config.database.host)
print(config.debug)
Environment variables can override nested keys using the program prefix. For example, MY_APP_DATABASE_HOST=prod.db and MY_APP_DEBUG=true will replace the corresponding fields after files are loaded.
Generating a default config
You can scaffold a TOML file with the model’s default values:
from bear_config.config_manager import ConfigManager
config_mgr = ConfigManager[Settings](Settings, program_name="my_app")
config_mgr.create_default_config() # writes default.toml into the local config dir
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bear_config-1.0.9-py3-none-any.whl.
File metadata
- Download URL: bear_config-1.0.9-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29cd1f034c75a1cf324328c8c6405b83ac4a595e616bfa3c173459f0302200ff
|
|
| MD5 |
dab6f5573d74023f4e15435885c6ab6d
|
|
| BLAKE2b-256 |
f2174ca96225d7d266a6bdc2cdfad44b1f101069af566cace33fad3769f57530
|
Provenance
The following attestation bundles were made for bear_config-1.0.9-py3-none-any.whl:
Publisher:
build-wheels.yml on sicksubroutine/bear-config
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bear_config-1.0.9-py3-none-any.whl -
Subject digest:
29cd1f034c75a1cf324328c8c6405b83ac4a595e616bfa3c173459f0302200ff - Sigstore transparency entry: 961032303
- Sigstore integration time:
-
Permalink:
sicksubroutine/bear-config@78ec51b2c6a9f08a6695eeb39c7b0253da2aba75 -
Branch / Tag:
refs/tags/v1.0.9 - Owner: https://github.com/sicksubroutine
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@78ec51b2c6a9f08a6695eeb39c7b0253da2aba75 -
Trigger Event:
push
-
Statement type: