pyamldantic
Validate and serialize YAML config files with Pydantic, with support for environment variables.
This package uses uv for project management. To get started, ensure that uv is installed on your machine and updated to the 0.5.6 version. Detailed installation instructions for uv can be found here.
Installation
uv add pyamldantic
Usage
config.yaml
database:
host: $DATABASE_HOST
name: $DATABASE_NAME
password: $DATABASE_PASSWORD
port: $DATABASE_PORT
user: $DATABASE_USER
timeout: $DATABASE_TIMEOUT?
environment: development
is_debug: true
config.py
from pyamldantic import YAMLConfig
from pydantic import BaseModel, SecretStr
class DatabaseSchema(BaseModel):
host: str
name: str
password: SecretStr
port: int
user: str
ssl: bool = False
timeout: int | None = None
class Schema(BaseModel):
database: DatabaseSchema
environment: str
is_debug: bool
config = YAMLConfig.load("config.yaml", schema=Schema)
main.py
from .config import config
if __name__ == "__main__":
print(f"Initializing {config.environment} environment...")
...
Development
uv sync --frozen --group=development
uv run --frozen pre-commit install --install-hooks
uv run --frozen pre-commit install --hook-type=commit-msg
Testing
uv sync --frozen --group=testing
uv run --frozen pytest
Acknowledgments
This project was inspired by envyaml.
Contributing
Contributions are welcome! To get started, please refer to our contribution guidelines.
Issues
If you encounter any problems while using this package, please open a new issue here.
Metadata
Release files for pyamldantic 1.3.0
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 | Actions |
|---|---|---|---|---|
| pyamldantic-1.3.0.tar.gz | 21.4 kB | Without provenance | Details for pyamldantic-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyamldantic-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for pyamldantic-1.3.0-py3-none-any.whl |
Total release size: 25.8 kB
Release files / pyamldantic-1.3.0.tar.gz
| Download URL | pyamldantic-1.3.0.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0660ae6c6b5588e64c531e506d0263913ceadb4041f7d15e3cc0a24c0478ad5
|
|
BLAKE2b-256 checksum How to use checksums |
8e78eca40841a9c35343c85de6bdbed0f74c96b50e124b54a6bdb8f21e3e9ce3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.5.6
|
Release files / pyamldantic-1.3.0-py3-none-any.whl
| Download URL | pyamldantic-1.3.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5ca23b8a507d62dbc003b020305d518a0f42bf6d086f97825b547dfdb5cb559
|
|
BLAKE2b-256 checksum How to use checksums |
01d45e89e251d86e8bb7c8fdabd65005429c08e4a44a399332b3e8824350470d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.5.6
|
Security for pyamldantic 1.3.0
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.