Describe the bug
When receiving a Request via kwargs, an IndexError occurs because it executes the code args[idx] if args else None before kwargs.get, under the following conditions:
To Reproduce

Expected behavior
It should first execute
and then
args[idx] if args else None
Screenshots

Your app (please complete the following information):
- My app is fastapi==0.138.1
-pPython3.14.6
- slowapi version is latest == 0.1.10
Additional context
The fix is simple: just rewrite line 726 in the file as

In code:
#request = kwargs.get("request", args[idx] if args else None) OLD
request = kwargs.get("request")
if not request:
request = args[idx] if args else None # NEW
Also for the synchronous version.
Describe the bug
When receiving a Request via kwargs, an IndexError occurs because it executes the code args[idx] if args else None before kwargs.get, under the following conditions:
To Reproduce

Expected behavior
It should first execute
and then
Screenshots

Your app (please complete the following information):
-pPython3.14.6
Additional context

The fix is simple: just rewrite line 726 in the file as
In code:
Also for the synchronous version.