Skip to main content

Easy environment variables management with type validation

Project description

easy-dotenv

PyPI version Python Versions License: MIT

Simple and type-safe environment variables management for Python.

Installation

pip install easy-dotenv

Usage

from easy_dotenv import EnvLoader

env = EnvLoader.load(
    # Required variables
    database_url=str,
    port=int,
    
    # Optional variables with defaults
    debug=(bool, False),
    workers=(int, 4)
)

# Access your environment variables
print(env.database_url)
print(env.port)
print(env.debug)  # False if not set
print(env.workers)  # 4 if not set

Features

  • Type validation
  • Required/optional variables
  • Default values
  • .env file support
  • Clean and simple API
  • Type hints support

Error Handling

from easy_dotenv import EnvLoader, EnvMissingError, EnvTypeError

try:
    env = EnvLoader.load(
        api_key=str,
        port=int
    )
except EnvMissingError as e:
    print("Missing environment variables:", e)
except EnvTypeError as e:
    print("Invalid environment variable type:", e)

Development

Setup

# Create virtual environment
python3 -m venv venv

# Activate virtual environment
source venv/bin/activate  # Linux/MacOS
# or
# venv\Scripts\activate  # Windows

# Install with development dependencies
pip install -e ".[dev]"

Running Tests

# Run tests
pytest

# Run tests with coverage
pytest --cov=easy_dotenv

License

MIT

Requirements

  • Python 3.7 or higher
  • python-dotenv>=0.19.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easy_dotenv-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easy_dotenv-0.1.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file easy_dotenv-0.1.1.tar.gz.

File metadata

  • Download URL: easy_dotenv-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for easy_dotenv-0.1.1.tar.gz
Algorithm Hash digest
SHA256 612d59a72ba6c4b797246cc6d9f85c0dbbececd8abcb1a09655d03ea8a268c14
MD5 e0ba6ac91846a3816435b52095db3d28
BLAKE2b-256 2621fc46ebf99f6fec5c8a4e9da59cd3a8a5c32ccc7096f821e546a3e5d2e185

See more details on using hashes here.

File details

Details for the file easy_dotenv-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: easy_dotenv-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for easy_dotenv-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81f25e14cc8cfbcc36a992023e3f4b852a48c0635657a2ec47ad508d0361024f
MD5 e7cdbe59ad43d4f54dbfb5d4eb1fc5c2
BLAKE2b-256 932598b0653e277c965d163bc3d2e39f30f99a65716541681bfb754580e6870b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page