| from pathlib import Path | |
| import os | |
| def load_local_env(path: str | Path = ".env") -> None: | |
| env_path = Path(path) | |
| if not env_path.exists(): | |
| return | |
| for line in env_path.read_text().splitlines(): | |
| stripped = line.strip() | |
| if not stripped or stripped.startswith("#") or "=" not in stripped: | |
| continue | |
| key, value = stripped.split("=", 1) | |
| key = key.strip() | |
| value = value.strip().strip('"').strip("'") | |
| if key and key not in os.environ: | |
| os.environ[key] = value | |