A metaclass for automatically loading and converting environment variables.
Project description
# pyenvloader `pyenvloader` is a Python package that provides a 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: ```bash pip install pyenvloader
Usage
To use pyenvloader
, define a class with pyenvloader.EnvLoader
as the metaclass and specify the environment variables with type annotations. Here’s an example:
-
Create a
.env
file in your project directory:env
API_ID=123456 API_HASH=your_api_hash BOT_TOKEN=your_bot_token OZ=11.2
-
Define your class using
EnvLoader
:python
from pyenvloader import EnvLoader class Env(metaclass=EnvLoader): API_ID: int API_HASH: str BOT_TOKEN: str OZ: float
-
Access the environment variables as class attributes:
python
print(Env.API_ID) # 123456 print(Env.API_HASH) # your_api_hash print(Env.BOT_TOKEN) # your_bot_token print(Env.OZ) # 11.2
Contributing
If you want to contribute to pyenvloader
, you can:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For any questions or issues, please contact Praveen.
### Key Sections: - **Features**: Summarizes what the package does. - **Installation**: Instructions for installing the package. - **Usage**: Examples of how to use the package. - **Contributing**: Guidelines for contributing to the project. - **License**: License information. - **Contact**: Contact information for further queries. Feel free to adjust the content based on any additional features or specific details about your package!
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
File details
Details for the file pyenvloadermeta-1.0.0.tar.gz
.
File metadata
- Download URL: pyenvloadermeta-1.0.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 392f341964c405aa98771598a752693f1e1da8ce19dfacbdc12a9bf4b35a64e9 |
|
MD5 | c4237999f7ab99018aaab24c1bc5d182 |
|
BLAKE2b-256 | 6b8a30bf9ee68a7e889c97147a8bc471ca4bca12eb551303eaf378eb8a5c4071 |
File details
Details for the file pyenvloadermeta-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pyenvloadermeta-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cb1ac1aa10b7741eed71e5d0d29133835c78293c7d90ce2de0319ce5cb6f518 |
|
MD5 | eb99fafc26689241423eaf9fce6c821c |
|
BLAKE2b-256 | a5a7c3bf54a276b2ecde504dc5ab551493459bce3b7a9120ef42c16aa1e845a9 |