Skip to main content

pipeline status coverage report

Typed Settings

PoC for library for managing (typed) settings – for server processes as well as commandline programms.

Requirements

  • Default settings are defined by app and can be overridden by config files, environment variables and click options.

  • You define settings as attrs class with types, converters and validators.

  • Attributes are basic data types (bool, int, float, str), lists of basic types, or nested settings classes.

  • Settings can be loaded from multiple config files.

  • Config files are allowed to contain settings for multiple apps (like pyproject.toml)

  • Paths to config files have to be explicitly named. Most defaults are not useful in many cases and have to be changed anyways.

  • Additional paths for config files can be specified via an environment variable. As in PATH, multiple paths are separated by a :. The last file in the list has the highest priority.

  • Environment variables with a defined prefix override settings from config files. This can optionally be disabled.

  • Click options for some or all settings can be generated. They are passed to the cli function as a single object (instead of individually).

  • Settings must be explicitly loaded, either via typed_settings.load_settings() or via typed_settings.click_options().

  • Both functions allow you to customize config file paths, prefixes et cetera.

Example

from attr import frozen, field
import click

import typed_settings as ts


@frozen
class Host:
    name: str
    port: int = field(converter=int)


@frozen(kw_only=True)
class Settings:
    url: str
    default: int = 3
    host: Host = field(converter=lambda d: Host(**d))


settings = ts.load_settings(
    settings_cls=Settings, appname='example', config_files=['settings.toml']
)
print(settings)


@click.command()
@ts.click_options(Settings, 'example', ['settings.toml'])
def main(settings):
    print(settings)


if __name__ == '__main__':
    main()

Metadata

Release files for typed-settings 0.3

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

Source distribution (sdist)

Source distribution for typed-settings 0.3
File Size Uploaded Provenance Actions
typed-settings-0.3.tar.gz 9.7 kB Without provenance Details for typed-settings-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for typed-settings 0.3
File Interpreter ABI Platform Actions
typed_settings-0.3-py3-none-any.whl Python 3 none any Details for typed_settings-0.3-py3-none-any.whl

Total release size: 16.5 kB

Release files / typed-settings-0.3.tar.gz

Download URL typed-settings-0.3.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e7cc22bf9eb2c4a94f8a9225163d7f7603a29a1b5297b71f3be7a60728da49a8
BLAKE2b-256 checksum
How to use checksums
1acff5704a3a9a9331d88a4db716697281184dbeaeee492679c597867119425c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

Release files / typed_settings-0.3-py3-none-any.whl

Download URL typed_settings-0.3-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc4ee980ba46b536a08f3a5ec380508ff0784d61861dd03d6df5c75b12814f1a
BLAKE2b-256 checksum
How to use checksums
24c633f1233c7d65fea801425471fb6c036bf6487befb9f3a0835fd6e8812c02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

Security for typed-settings 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files No provenance

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