Skip to content

Commit aa9eb7a

Browse files
committed
fix: only pass .env to config if it exists
1 parent 5c79615 commit aa9eb7a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

slowapi/extension.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import inspect
77
import itertools
88
import logging
9+
import os
910
import time
1011
from datetime import datetime
1112
from email.utils import formatdate, parsedate_to_datetime
@@ -154,8 +155,9 @@ def __init__(
154155

155156
self.logger = logging.getLogger("slowapi")
156157

158+
dotenv_file_exists = os.path.isfile(".env")
157159
self.app_config = Config(
158-
config_filename if config_filename is not None else ".env"
160+
".env" if dotenv_file_exists and config_filename is None else config_filename
159161
)
160162

161163
self.enabled = enabled

0 commit comments

Comments
 (0)