from __future__ import annotations import os from pathlib import Path PROJECT_ROOT = Path(__file__).resolve().parents[2] def load_env_file(path: Path = PROJECT_ROOT / ".env") -> None: if not path.exists(): return for line in path.read_text(encoding="utf-8").splitlines(): line = line.strip() if not line or line.startswith("#") or "=" not in line: continue key, value = line.split("=", 1) key = key.strip() value = value.strip().strip('"').strip("'") if key and key not in os.environ: os.environ[key] = value