Skip to content

Commit 6399cb3

Browse files
committed
flake8 fixes
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
1 parent d3b2ef9 commit 6399cb3

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

mcpgateway/alembic/versions/a706a3320c56_use_argon2id_for_encryption_key.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from cryptography.hazmat.primitives import hashes
2121
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
2222
from sqlalchemy import text
23+
import sqlalchemy as sa
2324

2425
# First-Party
2526
from mcpgateway.config import settings
@@ -133,6 +134,7 @@ def reencrypt_with_pbkdf2hmac(argon2id_bundle: str) -> Optional[str]:
133134
except Exception as e:
134135
raise ValueError("Invalid Argon2id bundle") from e
135136

137+
136138
def _reflect(conn):
137139
"""Reflect relevant tables.
138140
@@ -147,6 +149,7 @@ def _reflect(conn):
147149
a2a_agents = sa.Table("a2a_agents", md, autoload_with=conn)
148150
return {"gateways": gateways, "a2a_agents": a2a_agents}
149151

152+
150153
def _is_json(col):
151154
"""Check if a column is of JSON type.
152155
@@ -158,6 +161,7 @@ def _is_json(col):
158161
"""
159162
return isinstance(col.type, sa.JSON)
160163

164+
161165
def _looks_argon2_bundle(val: Optional[str]) -> bool:
162166
"""Heuristic for Argon2id bundle format (JSON with kdf=argon2id).
163167
@@ -255,11 +259,13 @@ def _upgrade_json_client_secret(conn, table):
255259
except json.JSONDecodeError as e:
256260
logger.warning("Skipping %s.id=%s: invalid JSON (%s)", table, rid, e)
257261
continue
258-
if not isinstance(cfg, dict): continue
262+
if not isinstance(cfg, dict):
263+
continue
259264

260265
old = cfg.get("client_secret")
261266
new = _upgrade_value(old) # your helper
262-
if not new: continue
267+
if not new:
268+
continue
263269

264270
cfg["client_secret"] = new
265271
value = cfg if _is_json(t.c.oauth_config) else json.dumps(cfg)
@@ -285,11 +291,13 @@ def _downgrade_json_client_secret(conn, table):
285291
except json.JSONDecodeError as e:
286292
logger.warning("Skipping %s.id=%s: invalid JSON (%s)", table, rid, e)
287293
continue
288-
if not isinstance(cfg, dict): continue
294+
if not isinstance(cfg, dict):
295+
continue
289296

290297
old = cfg.get("client_secret")
291298
new = _downgrade_value(old) # your helper
292-
if not new: continue
299+
if not new:
300+
continue
293301

294302
cfg["client_secret"] = new
295303
value = cfg if _is_json(t.c.oauth_config) else json.dumps(cfg)

mcpgateway/services/metrics.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,9 @@ def setup_metrics(app):
118118

119119
@app.get("/metrics/prometheus")
120120
async def metrics_disabled():
121-
"""Returns metrics response when metrics collection is disabled."""
121+
"""Returns metrics response when metrics collection is disabled.
122+
123+
Returns:
124+
Response: HTTP 503 response indicating metrics are disabled.
125+
"""
122126
return Response(content='{"error": "Metrics collection is disabled"}', media_type="application/json", status_code=status.HTTP_503_SERVICE_UNAVAILABLE)

0 commit comments

Comments
 (0)