Skip to content

Commit 99a12b4

Browse files
Added .env file
1 parent df093b5 commit 99a12b4

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

dynarag/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
import urllib.error
55
import urllib.request
66
from typing import Any, Dict, List, TypeVar, Optional, TypedDict, cast
7-
87
from dynarag.exceptions import BadAPIRequest, MissingAPIToken, BadEnvironment
98

109
LOGGER = logging.getLogger(__name__)
1110

11+
try:
12+
from dotenv import load_dotenv
13+
load_dotenv()
14+
LOGGER.info("Environment variables loaded from .env file if it exists")
15+
except ImportError:
16+
LOGGER.debug("python-dotenv not installed, skipping .env loading")
17+
1218
T = TypeVar("T")
1319

1420
class Similar(TypedDict):

poetry.lock

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ poethepoet = "^0.31.1"
1919
pytest = "^8.3.4"
2020
ruff = "^0.8.4"
2121
mypy = "^1.13.0"
22+
python-dotenv = "^1.0.1"
2223

2324
[build-system]
2425
requires = ["poetry-core"]

0 commit comments

Comments
 (0)