A Python utility for automatically managing environment variables with type safety and easy configuration.
Project description
Awesome Environment Manager
A Python utility for automatically managing environment variables with type safety and easy configuration.
Description
Environment Manager provides a simple yet powerful way to handle environment variables in Python applications through type-hinted class attributes. It automatically loads environment variables and converts them to the correct types based on your type hints.
Features
- 🔒 Type-safe environment variable handling
- 🔄 Automatic type conversion
- 📝 Support for
.envfiles (via python-dotenv) - 🎯 Support for various data types:
- Basic types (str, int, float, etc.)
- Boolean values with flexible input formats
- Lists with type hints (using semicolon as separator)
- Dictionaries (key-value pairs)
Installation
bash pip install awesome-environment-manager
or using uv
uv pip install awesome-environment-manager
Quick Start
from aem import EnvironmentClass
class AppConfig(EnvironmentClass):
DATABASE_URL: str = "postgresql://localhost"
PORT: int = 8080
DEBUG: bool = False
ALLOWED_HOSTS: list[str] = ["localhost", "127.0.0.1", "example.com"]
DB_CONFIG: dict = {"host": "localhost", "port": "5432", "name": "mydb"}
Create an instance - environment variables will be loaded automatically
os.environ["PORT"] = 8282
config = AppConfig()
print(config.DATABASE_URL) # => postgresql://localhost
print(config.PORT) # => 8282
Environment Variable Formats
-
Strings: Simple string values
DATABASE_URL=postgresql://localhost:5432/db -
Numbers: Will be converted to int/float
PORT=8080 -
Booleans: Supports various formats
DEBUG=true # Also accepts: 1, yes, y, on -
Lists: Use semicolons as separators
ALLOWED_HOSTS=localhost;127.0.0.1;example.com -
Dictionaries: Use semicolons between pairs and colons between keys and values
DB_CONFIG=host:localhost;port:5432;name:mydb
.env Support
The package automatically supports .env files if python-dotenv is installed:
pip install python-dotenv
Then create a .env file:
DATABASE_URL=postgresql://11.22.33.44
DEBUG=1
Result
config = AppConfig()
print(config.DATABASE_URL) # => postgresql://11.22.33.44
print(config.PORT) # => 8080
print(config.DEBUG) # => True
License
This project is licensed under the European Union Public License v1.2 (EUPL-1.2).
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 awesome_environment_manager-0.0.0.tar.gz.
File metadata
- Download URL: awesome_environment_manager-0.0.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
637b44ceca654da1f4c826ae51e1c0945d11ce74e58d3d26e93cb0798a042bae
|
|
| MD5 |
426dc3866eebae632f89587dbbd80782
|
|
| BLAKE2b-256 |
ee8b803bfbd4aa50b50b0c342e1183ebb1d0a6f3d2de99f0b88ce33a51943330
|
File details
Details for the file awesome_environment_manager-0.0.0-py3-none-any.whl.
File metadata
- Download URL: awesome_environment_manager-0.0.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c5d8d6fe12a270147a42be754f3d8d68b98e3559b484ef73ec8c35935863201
|
|
| MD5 |
d1705ac1a082f6cb9e048c8e158ee79b
|
|
| BLAKE2b-256 |
5dd08db331fceddfeafdca665abf9446ca8ff6d637ef9cb0e2834ec57f3ac97f
|