Coverage for app/extensions.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.14.3, created at 2026-06-28 23:33 +0000

1from flask import current_app # pyright: ignore[reportMissingImports] 

2from flask_caching import Cache # pyright: ignore[reportMissingImports] 

3from flask_limiter import Limiter # pyright: ignore[reportMissingImports] 

4from flask_limiter.util import get_remote_address # pyright: ignore[reportMissingImports] 

5 

6 

7def _rate_limiting_disabled() -> bool: 

8 """True when RATELIMIT_ENABLED=False — used as exempt_when on route-level limits. 

9 

10 Flask-limiter 4.x does not honour RATELIMIT_ENABLED for per-route @limiter.limit() 

11 decorators (only for the global default). This function makes the exemption explicit 

12 so that test fixtures that set RATELIMIT_ENABLED=False disable all limits correctly. 

13 It is a dict lookup and adds no measurable overhead per request. 

14 """ 

15 return not current_app.config.get("RATELIMIT_ENABLED", True) 

16 

17 

18cache = Cache() 

19 

20limiter = Limiter( 

21 get_remote_address, storage_uri="memory://", default_limits=["200 per minute"] 

22)