Skip to main content

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.

Release files for pydantic-env-settings 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-env-settings 0.1.1
File Size Uploaded
pydantic_env_settings-0.1.1.tar.gz 2.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-env-settings 0.1.1
File Interpreter ABI Platform
pydantic_env_settings-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.2 kB

Release files / pydantic_env_settings-0.1.1.tar.gz

Download URL pydantic_env_settings-0.1.1.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d4762a5f3c97949e2b5a5b6cd3d0046c7999123c188ab7123861e38763bc5d38
BLAKE2b-256 checksum
How to use checksums
935cf0adc0a7630d6e7479c0c405175a28fedf56f19f364a8d0f44e564858feb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.10.9 Linux/5.15.90.1-microsoft-standard-WSL2

Release files / pydantic_env_settings-0.1.1-py3-none-any.whl

Download URL pydantic_env_settings-0.1.1-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe337753bc4ef8b48a49220fe93c7e0e70eae6fb8886b0a465c95dc3fbc192ab
BLAKE2b-256 checksum
How to use checksums
ba4ee76482c937577feafa9a74553e291c9e2e390ec57b2cb33b4a280ea56527
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.10.9 Linux/5.15.90.1-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page