Source code for askemblaex.env

"""
askemblaex/env.py

Environment variable loading via python-dotenv.
"""

from __future__ import annotations

from pathlib import Path
from dotenv import load_dotenv


[docs] def load_env(env_file: Path | None = None) -> None: """ Load environment variables from a ``.env`` file. Called at module import time by most askemblaex modules so that credentials are available before any service clients are initialised. Args: env_file: Path to the ``.env`` file to load. Defaults to ``.env`` in the current working directory. A missing file is silently ignored. """ if env_file is None: env_file = Path(".env") if env_file.exists(): load_dotenv(env_file)