Merge branch 'laurentS:master' into master

This commit is contained in:
Colin Delahunty
2024-05-31 18:06:34 +01:00
committed by GitHub
3 changed files with 15 additions and 3 deletions

View File

@@ -1,5 +1,13 @@
# Change Log
## [0.1.9] - 2024-02-05
### Added
- Fix `limit_value` typehint in `limit()` function (thanks @PookieBuns)
- Fix `limit_value` typehint in `shared_limit()` function (thanks @aberlioz)
- Only pass `".env"` to starlette `Config` if `".env"` file exists (thanks @daniellok-db)
## [0.1.8] - 2023-04-07
### Added

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "slowapi"
version = "0.1.8"
version = "0.1.9"
description = "A rate limiting extension for Starlette and Fastapi"
authors = ["Laurent Savaete <laurent@where.tf>"]
license = "MIT"

View File

@@ -6,6 +6,7 @@ import functools
import inspect
import itertools
import logging
import os
import time
from datetime import datetime
from email.utils import formatdate, parsedate_to_datetime
@@ -154,8 +155,11 @@ class Limiter:
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
@@ -816,7 +820,7 @@ class Limiter:
def shared_limit(
self,
limit_value: Union[str, Callable[[str], str]],
limit_value: StrOrCallableStr,
scope: StrOrCallableStr,
key_func: Optional[Callable[..., str]] = None,
error_message: Optional[str] = None,