Skip to main content

Typed application settings on top of didactic Models.

Project description

didactic-settings

Typed application settings on top of dx.Model.

PyPI Python License CI Docs

Contributes didactic.settings to the namespace package.

Install

pip install didactic-settings
pip install 'didactic-settings[yaml]'   # adds YAML support

The package depends on didactic. The optional yaml extra adds PyYAML for .yaml / .yml config files.

Quickstart

import didactic.api as dx
from didactic.settings import Settings, EnvSource, FileSource


class AppSettings(Settings):
    debug: bool = False
    db_url: str
    port: int = 8080

    __sources__ = (
        FileSource(path="config.toml"),
        EnvSource(prefix="APP_"),
    )


cfg = AppSettings.load()
cfg.port                      # the resolved value
cfg.__provenance__["port"]    # 'env' / 'file' / 'default' / 'override'

Settings inherits from dx.Model, so every Model feature works: type checks, axioms, validators, JSON Schema export.

Sources

source reads from
EnvSource(prefix="APP_") environment variables
DotEnvSource(path=".env", prefix="APP_") dotenv file
FileSource(path="config.toml") JSON, TOML, or YAML by suffix
CliSource(args=ns) parsed argparse.Namespace or dict

Sources are walked in declaration order; later sources override earlier ones. Keyword overrides at Settings.load(...) win over every source.

Documentation

See Guides > Settings for the full source documentation, coercion rules, and provenance reporting.

License

Released under the MIT License.

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

didactic_settings-0.3.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

didactic_settings-0.3.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file didactic_settings-0.3.2.tar.gz.

File metadata

  • Download URL: didactic_settings-0.3.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for didactic_settings-0.3.2.tar.gz
Algorithm Hash digest
SHA256 93100ef972bfc0792a63d317f0f1606e8cb1b1ebeb8a4281091e9b7177168d0b
MD5 2fcf3f58623aea18596c62acf32e0f1e
BLAKE2b-256 99f5611d117ea7f4514f3d7789f5841320a5e84f25ca728a60b652e199e81395

See more details on using hashes here.

Provenance

The following attestation bundles were made for didactic_settings-0.3.2.tar.gz:

Publisher: release.yml on panproto/didactic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file didactic_settings-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for didactic_settings-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3aa0eb8e4ec61783d41cb72906a70d30a21c05d8e84b7f82c5d1565512aa8e6d
MD5 492f1cab76eb8195b08ee2ab03fd2834
BLAKE2b-256 f4d44b1270a3ff5f7ed64092952df18ab76f44e329a4170e21f0b9a9d82d3c8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for didactic_settings-0.3.2-py3-none-any.whl:

Publisher: release.yml on panproto/didactic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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