Pydantic BaseSettings Explicit
Project description
Pydantic Env Settings
Wrapper around BaseSettings.
Sets the usage of the .env file as default.
Modifies the error description while parsing .env file:
- marks it is a settings validation error
- renames the field names by adding the env_prefix and uppercaseing it
- gives hint about .env file
Installation
Using pip:
pip install pydantic-env-settings
Usage
class MySettings(EnvSettings):
filename: str
verbose: bool
class Config:
env_prefix = 'MY_'
settings = MySettings()
print(settings.filename)
print(settings.verbose)
Then your .env file should contain:
MY_FILENAME = /tmp/tempfile.bin
MY_VERBOSE = true
If your .env file does not exists or you have type errors in it you will see an error message like:
SettingsError: 2 validation errors for MySettings
MY_FILENAME
field required (type=value_error.missing)
MY_VERBOSE
field required (type=value_error.missing)
Hint! Verify your environment setting or the '.env' file.
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
Close
Hashes for pydantic_env_settings-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4762a5f3c97949e2b5a5b6cd3d0046c7999123c188ab7123861e38763bc5d38 |
|
MD5 | 32390097813742fdeae7f8e6ffb67587 |
|
BLAKE2b-256 | 935cf0adc0a7630d6e7479c0c405175a28fedf56f19f364a8d0f44e564858feb |
Close
Hashes for pydantic_env_settings-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe337753bc4ef8b48a49220fe93c7e0e70eae6fb8886b0a465c95dc3fbc192ab |
|
MD5 | d734b4ac7b924e2ed31909c4c96cae8a |
|
BLAKE2b-256 | ba4ee76482c937577feafa9a74553e291c9e2e390ec57b2cb33b4a280ea56527 |