Skip to content

Commit a6617c4

Browse files
committed
style: apply black formatting to all Python files
- Reformatted 78 files with black - Fixed code style issues across app/ and tests/ - Ensures consistent formatting for CI/CD checks
1 parent 8df2c7a commit a6617c4

78 files changed

Lines changed: 627 additions & 742 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/api/middleware/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@
6363
"create_gzip_middleware",
6464
"default_compression_config",
6565
]
66-

app/api/middleware/auth.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ def __init__(
210210
self._config = config or AuthConfig()
211211
self._authenticator = authenticator or APIKeyAuthenticator(self._config)
212212

213-
async def dispatch(
214-
self, request: Request, call_next: Callable
215-
) -> Response:
213+
async def dispatch(self, request: Request, call_next: Callable) -> Response:
216214
"""
217215
Process request with authentication.
218216
@@ -236,4 +234,3 @@ async def dispatch(
236234
auth_type=AuthType.API_KEY,
237235
api_keys=[],
238236
)
239-

app/api/middleware/compression.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ def _compress(self, body: bytes) -> bytes:
107107
"""Compress body using gzip."""
108108
return gzip.compress(body, compresslevel=self._config.compression_level)
109109

110-
async def dispatch(
111-
self, request: Request, call_next: Callable
112-
) -> Response:
110+
async def dispatch(self, request: Request, call_next: Callable) -> Response:
113111
"""
114112
Process request with compression.
115113
@@ -166,4 +164,3 @@ def create_gzip_middleware(minimum_size: int = 500):
166164
minimum_size=500,
167165
compression_level=6,
168166
)
169-

app/api/middleware/logging.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ def _truncate(self, text: str, max_length: int) -> str:
7777
return text
7878
return text[:max_length] + "...[truncated]"
7979

80-
async def dispatch(
81-
self, request: Request, call_next: Callable
82-
) -> Response:
80+
async def dispatch(self, request: Request, call_next: Callable) -> Response:
8381
"""
8482
Process request with logging.
8583
@@ -159,4 +157,3 @@ async def dispatch(
159157
log_response_body=False,
160158
slow_request_threshold_ms=1000.0,
161159
)
162-

app/api/middleware/rate_limiter.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ def __init__(
148148
self._config = config or RateLimitConfig()
149149
self._limiter = rate_limiter or InMemoryRateLimiter(self._config)
150150

151-
async def dispatch(
152-
self, request: Request, call_next: Callable
153-
) -> Response:
151+
async def dispatch(self, request: Request, call_next: Callable) -> Response:
154152
"""
155153
Process request with rate limiting.
156154
@@ -176,9 +174,7 @@ async def dispatch(
176174

177175
# Add rate limit headers
178176
remaining = self._limiter.get_remaining(request)
179-
response.headers["X-RateLimit-Limit"] = str(
180-
self._config.requests_per_minute
181-
)
177+
response.headers["X-RateLimit-Limit"] = str(self._config.requests_per_minute)
182178
response.headers["X-RateLimit-Remaining"] = str(remaining)
183179
response.headers["X-RateLimit-Reset"] = str(int(time.time()) + 60)
184180

@@ -192,4 +188,3 @@ async def dispatch(
192188
burst_size=10,
193189
enabled=True,
194190
)
195-

app/api/routes/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
from app.api.routes import docs, health, metrics, query
88

99
__all__ = ["health", "query", "metrics", "docs"]
10-

app/api/routes/docs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,3 @@ def get_openapi_config() -> Dict[str, Any]:
145145
},
146146
"latency_ms": 45.2,
147147
}
148-

app/api/routes/health.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ async def check_redis_health(request: Request) -> ComponentHealth:
5050

5151
try:
5252
if not hasattr(request.app.state, "app_state"):
53-
return ComponentHealth(status="unhealthy", message="App state not initialized")
53+
return ComponentHealth(
54+
status="unhealthy", message="App state not initialized"
55+
)
5456

5557
app_state = request.app.state.app_state
5658
if not app_state.redis_pool:
57-
return ComponentHealth(status="unhealthy", message="Redis pool not available")
59+
return ComponentHealth(
60+
status="unhealthy", message="Redis pool not available"
61+
)
5862

5963
from app.repositories.redis_repository import RedisRepository
6064

@@ -78,7 +82,9 @@ async def check_qdrant_health(request: Request) -> ComponentHealth:
7882

7983
try:
8084
if not hasattr(request.app.state, "app_state"):
81-
return ComponentHealth(status="unhealthy", message="App state not initialized")
85+
return ComponentHealth(
86+
status="unhealthy", message="App state not initialized"
87+
)
8288

8389
app_state = request.app.state.app_state
8490
if not app_state.qdrant_client:

app/api/routes/metrics.py

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -90,53 +90,38 @@ async def get_prometheus_metrics(request: Request) -> str:
9090
lines = []
9191

9292
# Application info
93-
lines.append(
94-
f'# HELP ragcache_info Application information'
95-
)
96-
lines.append(
97-
f'# TYPE ragcache_info gauge'
98-
)
99-
lines.append(
100-
f'ragcache_info{{version="0.1.0",environment="{config.app_env}"}} 1'
101-
)
93+
lines.append(f"# HELP ragcache_info Application information")
94+
lines.append(f"# TYPE ragcache_info gauge")
95+
lines.append(f'ragcache_info{{version="0.1.0",environment="{config.app_env}"}} 1')
10296

10397
# Pipeline metrics
10498
pipeline = metrics.get("pipeline", {})
10599
if pipeline:
106-
lines.append(f'# HELP ragcache_requests_total Total requests processed')
107-
lines.append(f'# TYPE ragcache_requests_total counter')
108-
lines.append(
109-
f'ragcache_requests_total {pipeline.get("total_requests", 0)}'
110-
)
111-
112-
lines.append(f'# HELP ragcache_cache_hits_total Total cache hits')
113-
lines.append(f'# TYPE ragcache_cache_hits_total counter')
100+
lines.append(f"# HELP ragcache_requests_total Total requests processed")
101+
lines.append(f"# TYPE ragcache_requests_total counter")
102+
lines.append(f'ragcache_requests_total {pipeline.get("total_requests", 0)}')
103+
104+
lines.append(f"# HELP ragcache_cache_hits_total Total cache hits")
105+
lines.append(f"# TYPE ragcache_cache_hits_total counter")
114106
lines.append(f'ragcache_cache_hits_total {pipeline.get("cache_hits", 0)}')
115107

116-
lines.append(f'# HELP ragcache_cache_hit_rate Cache hit rate')
117-
lines.append(f'# TYPE ragcache_cache_hit_rate gauge')
118-
lines.append(
119-
f'ragcache_cache_hit_rate {pipeline.get("cache_hit_rate", 0)}'
120-
)
108+
lines.append(f"# HELP ragcache_cache_hit_rate Cache hit rate")
109+
lines.append(f"# TYPE ragcache_cache_hit_rate gauge")
110+
lines.append(f'ragcache_cache_hit_rate {pipeline.get("cache_hit_rate", 0)}')
121111

122-
lines.append(f'# HELP ragcache_avg_latency_ms Average latency in ms')
123-
lines.append(f'# TYPE ragcache_avg_latency_ms gauge')
124-
lines.append(
125-
f'ragcache_avg_latency_ms {pipeline.get("avg_latency_ms", 0)}'
126-
)
112+
lines.append(f"# HELP ragcache_avg_latency_ms Average latency in ms")
113+
lines.append(f"# TYPE ragcache_avg_latency_ms gauge")
114+
lines.append(f'ragcache_avg_latency_ms {pipeline.get("avg_latency_ms", 0)}')
127115

128116
# Redis metrics
129117
cache = metrics.get("cache", {})
130118
if cache:
131-
lines.append(f'# HELP ragcache_redis_keys Total Redis keys')
132-
lines.append(f'# TYPE ragcache_redis_keys gauge')
119+
lines.append(f"# HELP ragcache_redis_keys Total Redis keys")
120+
lines.append(f"# TYPE ragcache_redis_keys gauge")
133121
lines.append(f'ragcache_redis_keys {cache.get("total_keys", 0)}')
134122

135-
lines.append(f'# HELP ragcache_redis_memory_bytes Redis memory usage')
136-
lines.append(f'# TYPE ragcache_redis_memory_bytes gauge')
137-
lines.append(
138-
f'ragcache_redis_memory_bytes {cache.get("memory_used_bytes", 0)}'
139-
)
123+
lines.append(f"# HELP ragcache_redis_memory_bytes Redis memory usage")
124+
lines.append(f"# TYPE ragcache_redis_memory_bytes gauge")
125+
lines.append(f'ragcache_redis_memory_bytes {cache.get("memory_used_bytes", 0)}')
140126

141127
return "\n".join(lines)
142-

app/api/versioning.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def get_router(self, version: APIVersion) -> APIRouter:
7979
APIRouter for the version
8080
"""
8181
if version not in self._routers:
82-
self._routers[version] = APIRouter(
83-
prefix=f"{self._prefix}/{version.value}"
84-
)
82+
self._routers[version] = APIRouter(prefix=f"{self._prefix}/{version.value}")
8583
return self._routers[version]
8684

8785
def include_router(
@@ -209,4 +207,3 @@ async def wrapper(*args, **kwargs):
209207
return wrapper
210208

211209
return decorator
212-

0 commit comments

Comments
 (0)