Skip to main content

Tiny Pydantic settings base class for quiet local and Docker file secrets

Project description

secret-backed-settings

Tiny Pydantic settings base class for projects that use environment variables plus local or Docker file secrets.

The package is intentionally small. It is not a configuration framework; it is a single BaseSettings subclass with a stable source-order contract.

Install

uv add secret-backed-settings

or:

pip install secret-backed-settings

For local ContentShuttle workspace development with uv, use the workspace source configured by the consuming project.

Usage

from pydantic_settings import SettingsConfigDict
from secret_backed_settings import SecretBackedSettings


class AppSettings(SecretBackedSettings):
    model_config = SettingsConfigDict(
        env_prefix="APP_",
        case_sensitive=False,
        extra="ignore",
    )

    api_key: str
    base_url: str

Environment variables use the configured prefix:

$env:APP_API_KEY = "env-token"
$env:APP_BASE_URL = "https://example.com"

File secrets use unprefixed field names:

.secrets/api_key
.secrets/base_url

Precedence

Values are loaded in this order:

  1. Explicit constructor values.
  2. Existing file secrets.
  3. Environment variables.
  4. Dotenv values.
  5. Field defaults.

Default secret directories are .secrets and /run/secrets. Missing default directories are ignored so local development and tests do not warn when Docker secrets are absent. Later directories override earlier directories, so /run/secrets wins over .secrets when both exist.

Pass _secrets_dir when a caller needs a different path:

settings = AppSettings(_secrets_dir="/path/to/secrets")

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

secret_backed_settings-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

secret_backed_settings-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file secret_backed_settings-0.1.0.tar.gz.

File metadata

  • Download URL: secret_backed_settings-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for secret_backed_settings-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8420314f1f5dfe1f4177ef9fc80cd8c72919d75dba37bd50178fb33cf605b0d8
MD5 b45358649e6e3dbb599da1ee5cf100fa
BLAKE2b-256 eaedcbee197996fd5fb5d3edec3197a27f395be70fe4c726ff3124d8ecbe640f

See more details on using hashes here.

File details

Details for the file secret_backed_settings-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: secret_backed_settings-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for secret_backed_settings-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52104960a7169f333e0d3bcd2ba03dc704eaf6ff8e9a2278f90de20719b2c265
MD5 0b37c071987acdb076e9ddc48be21f36
BLAKE2b-256 2403a5c63148928285712fcd91c091871e09b99e5ed2c7b7f1cab2726a924142

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