Skip to main content

Coverage Status Ruff License: MIT

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 = None
    DISABLE_AUTOTUNE: bool | None = 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`

Metadata

Release files for enfig 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enfig 1.0.2
File Size Uploaded Provenance Actions
enfig-1.0.2.tar.gz 37.5 kB With provenance Details for enfig-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for enfig 1.0.2
File Interpreter ABI Platform Actions
enfig-1.0.2-py3-none-any.whl Python 3 none any Details for enfig-1.0.2-py3-none-any.whl

Total release size: 42.6 kB

Release files / enfig-1.0.2.tar.gz

Download URL enfig-1.0.2.tar.gz
Size 37.5 kB
Tags Source
SHA-256 checksum
How to use checksums
113592810f5aad1d1cc9189922c900a8ba0f3461b00bcc101c93463b23456d02
BLAKE2b-256 checksum
How to use checksums
3f2c046a9a16b824b789715caab317b8bb92d7ed60994f4a15b50aea2b733d7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2025.

Transparency log

Release files / enfig-1.0.2-py3-none-any.whl

Download URL enfig-1.0.2-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b14d5ecc7876f3e72efb811437e1874a37533f1c5f77b96d61d95050a1685f9
BLAKE2b-256 checksum
How to use checksums
1047bf8e562f895485bc26465b630765b189e695f35bee437a7d4758ecf46924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2025.

Transparency log

Security for enfig 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for enfig-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page