style: clean up unused parameters and imports in examples

This commit is contained in:
2026-02-04 01:08:16 +00:00
parent 6bc108078f
commit d7966f7e96
11 changed files with 143 additions and 95 deletions

View File

@@ -14,20 +14,20 @@ from __future__ import annotations
import os
from contextlib import asynccontextmanager
from typing import Annotated
from fastapi import Depends, FastAPI, Request
from fastapi.responses import JSONResponse
from typing import Annotated
from fastapi_traffic import (
Algorithm,
MemoryBackend,
RateLimitExceeded,
RateLimiter,
RateLimitExceeded,
rate_limit,
)
from fastapi_traffic.core.limiter import set_limiter
from fastapi_traffic.backends.redis import RedisBackend
from fastapi_traffic.core.limiter import set_limiter
async def create_redis_backend():
@@ -94,7 +94,7 @@ LimiterDep = Annotated[RateLimiter, Depends(get_limiter)]
@app.exception_handler(RateLimitExceeded)
async def rate_limit_handler(request: Request, exc: RateLimitExceeded) -> JSONResponse:
async def rate_limit_handler(_: Request, exc: RateLimitExceeded) -> JSONResponse:
return JSONResponse(
status_code=429,
content={
@@ -113,7 +113,7 @@ async def rate_limit_handler(request: Request, exc: RateLimitExceeded) -> JSONRe
window_size=60,
key_prefix="shared",
)
async def shared_limit(request: Request) -> dict[str, str]:
async def shared_limit(_: Request) -> dict[str, str]:
"""This rate limit is shared across all application instances."""
return {
"message": "Success",
@@ -152,7 +152,7 @@ async def user_limit(request: Request) -> dict[str, str]:
burst_size=20,
key_prefix="burst",
)
async def burst_allowed(request: Request) -> dict[str, str]:
async def burst_allowed(_: Request) -> dict[str, str]:
"""Token bucket with Redis allows controlled bursts across instances."""
return {"message": "Burst request successful"}