Skip to main content

Environment Wrapped TOML

Project description

TOMLenv

GitHub Workflow Status PyPI - Version Pypi - Python Version PyPI - Downloads License

Environment wrapped TOML.

Package available in PyPI.

Getting Started

Install the library

Using pip:

$ pip install tomlenv

Using pipenv:

$ pipenv install tomlenv

Using poetry:

$ poetry add tomlenv

Basic Usage

Tomlenv takes advantage of modern Python features such as dataclasses and tomllib to create a simple yet powerful configuration library.

By default, tomlenv looks for a config.toml file in your project root:

token = "dev"
debug = false

Assuming this environment variable is set:

TOMLENV_DEBUG=true

Create your configuration dataclass and parse config and env into it:

import tomlenv
from dataclasses import dataclass

@dataclass
class Config:
    token: str = ''
    debug: 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

Configuration

To configure the location of your toml file, set TOMLENV_CONF_FILEPATH.

For example if your config file is in configs/config.toml relative to the project root, then set TOMLENV_CONF_FILEPATH=configs/config.toml

Tests

This project uses Poetry and GNU Make.

Run tests from the project root with:

$ make test

To get a coverage report:

$ make cov

Issues

Feel free to send issues or suggestions to https://github.com/joaonsantos/tomlenv/issues.

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.3.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

tomlenv-0.2.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file tomlenv-0.2.3.tar.gz.

File metadata

  • Download URL: tomlenv-0.2.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Linux/6.8.0-1017-azure

File hashes

Hashes for tomlenv-0.2.3.tar.gz
Algorithm Hash digest
SHA256 da47a7855b0a7675ea44482d19e5401ab0278d7448cf7b2ab7bdc62239530a58
MD5 95ccba054f80385b8f3104ec4684be44
BLAKE2b-256 cfad2822718aed38e3e9c9fd5e988cdf41609940039fbfe52d0931b473fdebe6

See more details on using hashes here.

File details

Details for the file tomlenv-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: tomlenv-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Linux/6.8.0-1017-azure

File hashes

Hashes for tomlenv-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0fb6a600a7c295dbfd4482a42fc0f0b6fc14734899fcde867782310af38c4435
MD5 bb980379772dc0d9818dfa1b96fc2459
BLAKE2b-256 37b3b7b7e197860713144999c5b2474a886c42d7c7b890b945a0d15501ef1752

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