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.2.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.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: easy_dotenv-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 8de664ab8f91319671d021faa643e4c9b7910d940413b70d95c32e64db046170
MD5 5c9f03339c46211b153116c899896488
BLAKE2b-256 2812468f7ecdfc5610882b75d574f51e747cd47904d9ef023a53755b8e6880f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easy_dotenv-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d50efd0e3e1945df3f2685c0ebcf0c290f804bdde3556b8340187721e49eec8
MD5 db2a99f1c0cce5f4e494d42e00a53c27
BLAKE2b-256 ede9916e5a266c060ca448f318c278d92baec6494bc032c17fcf6730810b3506

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