Minimal environment variable helpers with explicit failure semantics.
Project description
paraboloski-dotenv
Lightweight wrapper around os.getenv() inspired by Go: explicit config, fail-fast startup, no silent misconfiguration.
- use
env()when a value can have a fallback - use
require()when the application cannot run without it
Install
uv add paraboloski-dotenv
pip install paraboloski-dotenv
GitHub:
uv add git+https://github.com/paraboloski/snippet-toolbox/python#subdirectory=snippet/paraboloski-dotenv
env() vs require()
env() |
require() |
|
|---|---|---|
| Missing value | fallback or error | immediate crash (panic) |
| Use case | optional config | required config |
Usage
from dotenv import env, require
# optional
POOL_SIZE = int(env("POOL_SIZE", "10"))
TIMEOUT = int(env("TIMEOUT", "30"))
# required
DATABASE_URL = require("DATABASE_URL")
JWT_SECRET = require("JWT_SECRET")
Production behavior
Missing required variable:
[PANIC] Missing environment variable: 'DATABASE_URL'
exit code 1
App fails fast instead of starting in a broken state.
Compared to os.getenv()
# fragile
DATABASE_URL = os.getenv("DATABASE_URL")
if not DATABASE_URL:
raise RuntimeError("missing")
vs
# explicit
DATABASE_URL = require("DATABASE_URL")
Less boilerplate. Clear intent. Safer startup.
Italiano
Wrapper leggero di os.getenv() ispirato a alla filosofia di Go: configurazione esplicita e fail-fast.
- Utilizzare
env()quando un valore può avere un valore di fallback - Utilizzare
require()quando l'applicazione non può funzionare senza di esso
Installazione
uv add paraboloski-dotenv
pip install paraboloski-dotenv
GitHub:
uv add git+https://github.com/paraboloski/snippet-toolbox/python#subdirectory=snippet/paraboloski-dotenv
env() vs require()
env() |
require() |
|
|---|---|---|
| Valore mancante | fallback o errore | crash immediato (panic) |
| Uso | config opzionale | config obbligatoria |
Utilizzo
from dotenv import env, require
# opzionale
POOL_SIZE = int(env("POOL_SIZE", "10"))
TIMEOUT = int(env("TIMEOUT", "30"))
# obbligatorio
DATABASE_URL = require("DATABASE_URL")
JWT_SECRET = require("JWT_SECRET")
Comportamento in produzione
Variabile mancante:
[PANIC] Missing environment variable: 'DATABASE_URL'
exit code 1
L'app si ferma subito invece di partire in stato incoerente.
Confronto con os.getenv()
# fragile
DATABASE_URL = os.getenv("DATABASE_URL")
if not DATABASE_URL:
raise RuntimeError("missing")
vs
# esplicito
DATABASE_URL = require("DATABASE_URL")
Meno boilerplate. Intento chiaro. Avvio più sicuro.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paraboloski_dotenv-1.0.0.tar.gz.
File metadata
- Download URL: paraboloski_dotenv-1.0.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1822108e24d80104addf7dbdba904cc1dfd5de559780d46fc8c2810aa019925c
|
|
| MD5 |
c7cefce6eec9c3d8f1ed1f5bb8bfeaea
|
|
| BLAKE2b-256 |
7ee75afb11d8f46c3e6ba8f3b871c04cf9be175f760ee64eb3cce35e9e02b84f
|
File details
Details for the file paraboloski_dotenv-1.0.0-py3-none-any.whl.
File metadata
- Download URL: paraboloski_dotenv-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
958c9db971a1b2b7583f63e800edc42e90f8c37ba7e134c7e45673d476885b47
|
|
| MD5 |
ddec85b2defbb9d46ab9999ff3c41b52
|
|
| BLAKE2b-256 |
dc4017099912b4cc2740a6ed11be763a1b08930117764fbcb56a62e2c0441a3c
|