Skip to content

Commit

Permalink
fix: only pass .env to config if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellok-db committed Feb 5, 2024
1 parent 5c79615 commit aa9eb7a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion slowapi/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import inspect
import itertools
import logging
import os
import time
from datetime import datetime
from email.utils import formatdate, parsedate_to_datetime
Expand Down Expand Up @@ -154,8 +155,9 @@ def __init__(

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

dotenv_file_exists = os.path.isfile(".env")
self.app_config = Config(
config_filename if config_filename is not None else ".env"
".env" if dotenv_file_exists and config_filename is None else config_filename
)

self.enabled = enabled
Expand Down

0 comments on commit aa9eb7a

Please sign in to comment.