diff --git a/flask_limiter/__init__.py b/flask_limiter/__init__.py index c21a95a..d06d40f 100644 --- a/flask_limiter/__init__.py +++ b/flask_limiter/__init__.py @@ -1,4 +1,5 @@ """Flask-Limiter extension for rate limiting.""" + from . import _version from .constants import ExemptionScope, HeaderNames from .errors import RateLimitExceeded diff --git a/flask_limiter/commands.py b/flask_limiter/commands.py index f66c77a..848bb4d 100644 --- a/flask_limiter/commands.py +++ b/flask_limiter/commands.py @@ -124,12 +124,14 @@ def render_limits( "blueprint" if blueprint and limit in limiter.limit_manager.blueprint_limits(app, blueprint) - else "route" - if limit - in limiter.limit_manager.decorated_limits( - get_qualified_name(view_func) if view_func else "" + else ( + "route" + if limit + in limiter.limit_manager.decorated_limits( + get_qualified_name(view_func) if view_func else "" + ) + else "default" ) - else "default" ) else: source = "default" diff --git a/flask_limiter/extension.py b/flask_limiter/extension.py index 4093f0d..cfbd870 100644 --- a/flask_limiter/extension.py +++ b/flask_limiter/extension.py @@ -1,6 +1,7 @@ """ Flask-Limiter Extension """ + from __future__ import annotations import dataclasses @@ -651,8 +652,7 @@ def exempt( obj: flask.Blueprint, *, flags: ExemptionScope = ExemptionScope.APPLICATION | ExemptionScope.DEFAULT, - ) -> flask.Blueprint: - ... + ) -> flask.Blueprint: ... @overload def exempt( @@ -660,8 +660,7 @@ def exempt( obj: Callable[..., R], *, flags: ExemptionScope = ExemptionScope.APPLICATION | ExemptionScope.DEFAULT, - ) -> Callable[..., R]: - ... + ) -> Callable[..., R]: ... @overload def exempt( @@ -671,8 +670,7 @@ def exempt( ) -> Union[ Callable[[Callable[P, R]], Callable[P, R]], Callable[[flask.Blueprint], flask.Blueprint], - ]: - ... + ]: ... def exempt( self, @@ -1252,16 +1250,13 @@ def __exit__( exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType], - ) -> None: - ... + ) -> None: ... @overload - def __call__(self, obj: Callable[P, R]) -> Callable[P, R]: - ... + def __call__(self, obj: Callable[P, R]) -> Callable[P, R]: ... @overload - def __call__(self, obj: flask.Blueprint) -> None: - ... + def __call__(self, obj: flask.Blueprint) -> None: ... def __call__( self, obj: Union[Callable[P, R], flask.Blueprint] diff --git a/tests/test_decorators.py b/tests/test_decorators.py index f638783..6b25de9 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -705,8 +705,7 @@ def default_on_breach_with_response(request_limit): f"default custom response {request_limit.limit} @ {request.path}", 429 ) - def on_breach_invalid(): - ... + def on_breach_invalid(): ... def on_breach_fail(request_limit): 1 / 0 diff --git a/tests/test_flask_ext.py b/tests/test_flask_ext.py index 784060b..747a967 100644 --- a/tests/test_flask_ext.py +++ b/tests/test_flask_ext.py @@ -1,6 +1,7 @@ """ """ + import logging import time from collections import Counter diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 83c4cf1..3bf03da 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -1,6 +1,7 @@ """ """ + import time import hiro