_DOTENV_LOADED = False def ensure_env_loaded() -> None: global _DOTENV_LOADED if _DOTENV_LOADED: return try: # Lazy import to avoid hard failure if not installed from dotenv import load_dotenv, find_dotenv # type: ignore path = find_dotenv(usecwd=True) if path: load_dotenv(dotenv_path=path, override=False) else: # Fall back to default discovery in CWD load_dotenv(override=False) except Exception: # Silently ignore if python-dotenv is not available or errors out pass _DOTENV_LOADED = True