Metadata-Version: 2.4
Name: structconfig
Version: 0.1.0
Project-URL: Homepage, https://github.com/pzarczynski/structconfig
Project-URL: Issues, https://github.com/pzarczynski/structconfig/issues
Author-email: pzarczynski <piotr.zarczynski.06@gmail.com>
License: MIT
License-File: LICENSE
Keywords: config,dataclasses,env,settings,toml
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: msgspec>=0.21.1
Requires-Dist: python-dotenv>=1.2.2
Description-Content-Type: text/markdown

# structconfig

[![CI](https://github.com/pzarczynski/structconfig/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/pzarczynski/structconfig/actions/workflows/ci.yml)

Strongly-typed configuration for Python, powered by `msgspec`.

load configuration from multiple sources with clear precedence:

- CLI arguments (highest priority)
- Environment variables
- `.env` files
- TOML / JSON / YAML files
- Struct field defaults (lowest priority)

## Quick Start

```python
from structconfig import Struct, field, load_config


class DatabaseConfig(Struct):
    host: str = "localhost"
    port: int = 5432


class AppConfig(Struct):
    api_key: str  # required field
    debug: bool = False
    db: DatabaseConfig = field(default_factory=DatabaseConfig)


# load_config from TOML file + env vars
config = load_config(
    AppConfig,
    files=["config.toml"],
    env_prefix="APP",
)
print(config.api_key)
```

## License

This project is a modified fork of [saneconfig](https://github.com/srichs/saneconfig), licensed under MIT.