Pydantic utility helpers
Project description
pydanticutils
Pydantic utility helpers
Usage
- Install the package from pypi
> pip install pydanticutils
- Create a pydantic settings class
class DatabaseSettings(BaseModel):
host: str = Field(default="0.0.0.0")
port: int = Field(default=5432)
class AppSettings(BaseSettings):
model_config = SettingsConfigDict(env_prefix="APP_", env_nested_delimiter="__")
log_level: str = Field(default="INFO")
database: DatabaseSettings = Field(default_factory=DatabaseSettings)
- Read a configuration file into the settings class
from pydanticutils import read_yaml
settings = read_yaml("/path/to/config.yaml", AppSettings)
Development
This repository manages the dev environment as a Nix flake and requires Nix to be installed
> nix develop -c $SHELL
> make setup
> make test
Publish Package to PyPi
> make distribution
License
pydanticutils
is released under the MIT license
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
pydanticutils-0.0.3.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for pydanticutils-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13de2540373a42500ea8a889b710da3a3a1250048967b1a048beda9ce7c5f116 |
|
MD5 | 685819bf05a19dbee6dc8e2ba66b3d65 |
|
BLAKE2b-256 | 27793e9385cc5b220667b4dc7a4b12ac9877e91491a8862bc86ad3cd80740438 |