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.2.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for pydanticutils-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18b2d825cdc986ae08b1868ff7785d8d92d5f86a59aba3c9945c7fc1b4fc9fe5 |
|
MD5 | 2eac19a862cc6abdc442eb935e6d247e |
|
BLAKE2b-256 | b13e7337bd101c95109304a42166f13181ebe3978d1a5cf46061a66ce45f4c3d |