Skip to main content

loadenv

Automatically load environment variables into structured Python data

Loadenv makes it easy to pull environment variables into your program. It centralizes and hides the task of loading environment variables and asserting necessary variables are set, while assigning default values for those that are not required.

Loaded variables are cast to python objects based on type annotations and stored as identifiers, not strings. So typo bugs are easier to catch and names are easier to autocomplete. It does all this during startup, making bad invocations quit as soon as possible and with a clear error message, rather than deep in business logic from strange Exceptions.

Getting Started

Define an EnvEnum where each member is named exactly as the environment variable you wish to capture. It should be annotated with the type you would like the member to be. You will have to assign some value to the member to actually create it. For required environment variable this value does not matter; values such as () or ... are good choices.

from loadenv import EnvEnum


# values are taken from the environment when the class is created
class Secrets(EnvEnum):
    USERNAME: str = ()
    USERPASS: str = ()
    USERAPIKEY: str = ()


# later on
requests.post(prod, headers={"Authorization": f"TOK:{Secrets.USERAPIKEY}"})

Metadata

Release files for loadenv 0.1.1

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

Source distribution (sdist)

Source distribution for loadenv 0.1.1
File Size Uploaded Provenance
loadenv-0.1.1.tar.gz 7.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 14.4 kB

Release files / loadenv-0.1.1.tar.gz

Download URL loadenv-0.1.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8dde4a80cf733323880c118659685d822f9d1311fa15b3d7e1e2aa28223aba29
BLAKE2b-256 checksum
How to use checksums
d7a24ef0013d1683cdcd29ea254e3a02ac43f25323842fc8d59983eb17608f47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release files / loadenv-0.1.1-py3-none-any.whl

Download URL loadenv-0.1.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e06a1d86ea1ad89a96aeb470d27de8d569a980ad7c6fd0dd0ee416cc11919853
BLAKE2b-256 checksum
How to use checksums
d0bae29b2a5d12d5fad9c037ad7d5c3dffb22864d6511310bffa414c56408995
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Security for loadenv 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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