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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_env_settings-0.1.0.tar.gz.
File metadata
- Download URL: pydantic_env_settings-0.1.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.9 Linux/6.1.8-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fcca81fdd0ad086d8fc6bd790a6f15901a116f2c910d5fb01fef4437bbe1864
|
|
| MD5 |
ba5e0fead6de5cec0bfd9c7c8a117134
|
|
| BLAKE2b-256 |
d051705224794c4195c41d49376fc80618d89d4fee38f6317363689688f2b048
|
File details
Details for the file pydantic_env_settings-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydantic_env_settings-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.9 Linux/6.1.8-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7256924e7d0d26e09facabe0cd218dad71044857bbd2c6982df6330ee71c9f34
|
|
| MD5 |
f4d02f5d63c6d6944ee7d64d87d9c78f
|
|
| BLAKE2b-256 |
ad27f5ebfe4a67c1c91d4e125861d13ea24eae8c0800dd58d7e70701dd24cc6f
|