Lean, zero dependency environment parsing library.
Project description
Enfig - Environment Config
Lean, zero dependency environment parsing library based on annotations, inspired by pydantic.
Environmental variables are being parsed and casted automatically to the corresponding type when class variables are being accessed.
Examples:
import os
import enfig
# Just for demonstration, of course env vars should already be set outside the application.
os.environ["COLOR"] = "RED"
os.environ["TEMPERATURE"] = "50"
os.environ["DISABLE_AUTOTUNE"] = "y"
class Config(enfig.BaseConfig):
COLOR: str
TEMPERATURE: int
DISABLE_AUTOTUNE: bool
assert Config.COLOR == "RED"
assert Config.TEMPERATURE == 50
assert Config.DISABLE_AUTOTUNE is True
The Config class casts the values automatically.
Moreover, you can test if all mandatory variables have been set and have the correct type.
import os
import enfig
os.environ["COLOR"] = "RED"
os.environ["DISABLE_AUTOTUNE"] = "I can't sing but I pretend to be a singer"
os.environ["WEIGHT"] = "haha invalid"
class Config(enfig.BaseConfig):
COLOR: str
TEMPERATURE: int
WEIGHT: float
AMOUNT: int = None
DISABLE_AUTOTUNE: bool = None
try:
Config.validate()
except enfig.ValidationError as error:
for attribute_error in error.errors:
print(attribute_error)
Output:
DISABLE_AUTOTUNE: Invalid value, required type: `bool`
TEMPERATURE: Not set, required type: `int`
WEIGHT: Invalid value, required type: `float`
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 enfig-1.0.0.tar.gz.
File metadata
- Download URL: enfig-1.0.0.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cc5826627ad311463417794c960c6fdd9b9a4a7774b559c6810281f16ff349e
|
|
| MD5 |
27c11f2d16e7cf7e5ee9177717f290d8
|
|
| BLAKE2b-256 |
c6ec5fef53e7b0a076dc6522b8bf6b830a1a92acb1e86f896ab70b5c09e74f07
|
Provenance
The following attestation bundles were made for enfig-1.0.0.tar.gz:
Publisher:
CD.yml on datek/enfig
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
enfig-1.0.0.tar.gz -
Subject digest:
4cc5826627ad311463417794c960c6fdd9b9a4a7774b559c6810281f16ff349e - Sigstore transparency entry: 312317052
- Sigstore integration time:
-
Permalink:
datek/enfig@277019cc4c1347f6917270fea6fde2194a534381 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/datek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CD.yml@277019cc4c1347f6917270fea6fde2194a534381 -
Trigger Event:
create
-
Statement type:
File details
Details for the file enfig-1.0.0-py3-none-any.whl.
File metadata
- Download URL: enfig-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac3a6209f630c04182dbc94cd8cc391f9198d99d29026f1c362f17503056bb15
|
|
| MD5 |
ce1f72a8df8086cb6439963633b6c6d7
|
|
| BLAKE2b-256 |
9feae39904568e1274d32bcab2a8a00ee0cd7229bc74117b39b581de7dee90a0
|
Provenance
The following attestation bundles were made for enfig-1.0.0-py3-none-any.whl:
Publisher:
CD.yml on datek/enfig
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
enfig-1.0.0-py3-none-any.whl -
Subject digest:
ac3a6209f630c04182dbc94cd8cc391f9198d99d29026f1c362f17503056bb15 - Sigstore transparency entry: 312317063
- Sigstore integration time:
-
Permalink:
datek/enfig@277019cc4c1347f6917270fea6fde2194a534381 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/datek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CD.yml@277019cc4c1347f6917270fea6fde2194a534381 -
Trigger Event:
create
-
Statement type: