Skip to main content

Environment Wrapped TOML

Project description

TOMLenv

Environment wrapped TOML.

Getting Started

Install the library

Using pip:

$ pip install tomlenv

Using pipenv:

$ pipenv install tomlenv

Using poetry:

$ poetry add tomlenv

Basic Usage

Assuming you have this TOML file:

token = "dev"
debug = false

And this environment set:

TOMLENV_DEBUG=true

Create your configuration dataclass and parse configuration into it:

import tomlenv

class Config:
    token: str | None = ""
    enabled: bool = False

config = Config()
parser = tomlenv.Parser()

parser.load(config)

# You can now access the fields of your fully typed Config class
# that contains values from a TOML config file and the environment.
#
# For example:

token = config.token
debug = config.debug
print(token) # prints "dev"
print(debug) # prints True

Tests

This project uses Poetry and GNU Make.

Run tests from the project root with:

$ make test

To get a coverage report:

$ make cov

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

tomlenv-0.2.0.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

tomlenv-0.2.0-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

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