Skip to main content

Yet Another Python Envvar Config Object

Project description

yapeco: Yet Another Python Envvar Config Object

A positively miniscule utility module to access .env (and otherwise environment-defined) config values through a Python object. Created out of annoyance with not being able to autocomplete said envvars in my editor :^)

Usage

Installation:

pip3 install yapeco

A simple example:

# -- [mock environment] ---------------------------
API_KEY=abc123
DELAY_MSEC=18
FEATURE_A_ENABLED=false
FEATURE_B_ENABLED=1
# --- config.py -----------------------------------

from yapeco import BaseEnvironment as Env

class Config(Env):
    api_key: str
    delay_msec: int
    feature_a_enabled: bool
    feature_b_enabled: bool


# --- main.py -------------------------------------

from config import Config

Config.api_key # "abc123"
Config.delay_msec # 18
Config.feature_a_enabled # False
Config.feature_b_enabled # True

Features & Limitations

  • Case-insensitive + SNAKE_case field names
  • Primitives such as str, bool, int and float are supported (no guarantees with the latter, though)
  • Common boolean config formats (i.e. VAR=0/1/true/false/True/False) work as expected
  • Errors at start time if an environment variable is not found
  • Does not support types from typing, e.g. Optional[str]

Development

Requires poetry.

poetry install # install dependencies
poetry build # build package
poetry run pytest # run tests

Extra

Pedantic note:

As in Smalltalk, classes themselves are objects.

The Literal Python Documentation

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

yapeco-0.1.0.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

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

yapeco-0.1.0-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yapeco-0.1.0.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.6 Darwin/23.0.0

File hashes

Hashes for yapeco-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e10fd54480753e480750dff75dc1172b058853d24d86b3b8789950d0d8ec19bf
MD5 5e6e8c5b9b16e21151dbbfdb9d24f2c9
BLAKE2b-256 61fe67982eff0d9f18538dbf41bc44b141c87ec024adbba00cadd01fdca7a6b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yapeco-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.6 Darwin/23.0.0

File hashes

Hashes for yapeco-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0de0251ef4c5e4e0a465a7e511f02c4c3c557bf5962b82b8388039acd294e32
MD5 323b45c5d4a58557acd386bd4908dce0
BLAKE2b-256 d2d2e188bcd0ec466de4f6f531c2369533db68fef5ac4a37c4c61c7540850ee7

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