Skip to main content

PyEnvloaderMeta - metaclass for automatically loading and converting environment variables into class attributes.

  • It simplifies the process of managing environment variables by leveraging type annotations and the python-dotenv package.
  • Features - Automatically loads environment variables from a .env file.
  • Converts environment variables to specified types using type annotations.
  • Raises errors if required environment variables are missing or cannot be converted.

Installation You can install pyenvloader from PyPI using pip:

pip install pyenvloadermeta

Usage

To use pyenvloadermeta, define a class with pyenvloadermeta.EnvLoaderMeta as the metaclass and specify the environment variables with type annotations. Here’s an example:

  1. Create a .env file in your project directory:

.env

API_ID=123456
API_HASH=dfdafdfasdff
BOT_TOKEN=fasdfasfdafsd
OZ=11.2
POKEMON=["Pikachu", "Raichu's"]
  1. Define your class using EnvLoaderMeta:
from pyenvloadermeta import EnvLoaderMeta

class Env(metaclass=EnvLoaderMeta):
	API_ID: int
	API_HASH: str
	BOT_TOKEN: str
	OZ: float
	POKEMON: list[str]
  1. Access the environment variables as class attributes:
print(Env.API_ID)
print(Env.API_HASH)
print(Env.BOT_TOKEN)
print(Env.OZ)
print(Env.POKEMON)

Release files for pyenvloadermeta 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 pyenvloadermeta 1.0.2
File Size Uploaded
pyenvloadermeta-1.0.2.tar.gz 2.6 kB Details

Built distribution (wheel)

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

Total release size: 5.4 kB

Release files / pyenvloadermeta-1.0.2.tar.gz

Download URL pyenvloadermeta-1.0.2.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d934dd5da616ccf7449b66e70faf2d66cbeac4125262e7700bc6441f4ac32a13
BLAKE2b-256 checksum
How to use checksums
b23c0dbae653a8798b4b3fcba9d4a2e2fe572c54816f665c99aa43e71cc469af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

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

Download URL pyenvloadermeta-1.0.2-py3-none-any.whl
Size 2.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
860732b08509eae8cdddddd3fe9f8391abdee4ef74066fe781f55073cff3a79b
BLAKE2b-256 checksum
How to use checksums
5860338339596dcccf6fa44ab7b5c0b7d5d38c20227cfb8fb4998af6be50cc6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

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