A Python library for managing configuration files using TOML and environment variables
Project description
PyMicroConf
A lightweight, type-safe TOML configuration loader with environment variable overrides for Python applications.
PyMicroConf provides a simple way to manage application configuration using TOML files while supporting environment variable overrides. It uses Python dataclasses and type annotations for type safety and automatic validation.
Features
- Lightweight: Minimal dependencies, uses only Python standard library
- Type-safe: Full type checking with dataclasses and type annotations
- Environment Override: Environment variables take precedence over config files
- Nested Configuration: Support for nested configuration structures
- Automatic Validation: Built-in validation for required fields and types
- Easy to Use: Intuitive API with minimal boilerplate
Installation
pip install pymicroconf
Usage
Define a configuration class using dataclasses and type annotations:
from pathlib import Path
from typing import Annotated
from pymicroconf import ConfigHandler, ConfigField, BaseConfig
class AppConfig(BaseConfig):
api_key: Annotated[str, ConfigField("API_KEY", required=True)]
database_url: Annotated[str, ConfigField("DATABASE_URL", required=True)]
debug: Annotated[str, ConfigField("DEBUG", default=False)]
config = Config(Path("config.toml"), AppConfig).load_config()
Access configuration values:
print(config.api_key)
print(config.database_url)
print(config.debug)
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 Distribution
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 pymicroconf-0.1.0.tar.gz.
File metadata
- Download URL: pymicroconf-0.1.0.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98e79fa0f045a96dd5a686ffae96037980460231f063b2e980d02e4e99cdabcd
|
|
| MD5 |
4bcebffe5e1305694941671db6143338
|
|
| BLAKE2b-256 |
4b055ab7b62bbf7bd4bb3dbed152a520a223548a83a05f9fffff0eace637724a
|
File details
Details for the file pymicroconf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pymicroconf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d4e5486145008cad0b0868b6221088c1c1d665f38c4672f25a458ba4b9013bf
|
|
| MD5 |
f7b244afd1c5d198ca899bedd936cd3c
|
|
| BLAKE2b-256 |
663e4a93ea39e6d827c85e8e5e351f1d8d484c3e1c318cd19c23b0d63879887f
|