Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_env_settings-0.1.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_env_settings-0.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_env_settings-0.1.1.tar.gz.

File metadata

  • Download URL: pydantic_env_settings-0.1.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.9 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for pydantic_env_settings-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d4762a5f3c97949e2b5a5b6cd3d0046c7999123c188ab7123861e38763bc5d38
MD5 32390097813742fdeae7f8e6ffb67587
BLAKE2b-256 935cf0adc0a7630d6e7479c0c405175a28fedf56f19f364a8d0f44e564858feb

See more details on using hashes here.

File details

Details for the file pydantic_env_settings-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pydantic_env_settings-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.9 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for pydantic_env_settings-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe337753bc4ef8b48a49220fe93c7e0e70eae6fb8886b0a465c95dc3fbc192ab
MD5 d734b4ac7b924e2ed31909c4c96cae8a
BLAKE2b-256 ba4ee76482c937577feafa9a74553e291c9e2e390ec57b2cb33b4a280ea56527

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page