Skip to content

Commit 2edc3e4

Browse files
committed
chore(format): pre-rebase autoflake + isort + black + ruff format pass
Applies formatter output from the current toolchain to align the branch with upstream pre-commit hooks (ruff check + formatter, PR #5169) before rebasing onto main. Absorbs trivial format-only conflicts (f-string concatenation cleanup, import reordering, isort comment groupers) so the rebase replays substantive work only. No semantic changes. Generated by: make autoflake isort black make ruff RUFF_MODE=format Signed-off-by: Jonathan Springer <jps@s390x.com>
1 parent 6b9c0b3 commit 2edc3e4

13 files changed

Lines changed: 36 additions & 19 deletions

mcpgateway/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,6 +3100,7 @@ async def admin_add_server(request: Request, db: Session = Depends(get_db), user
31003100
# Ensure default visibility is private and assign to personal team when available
31013101
team_id_cast = typing_cast(Optional[str], team_id)
31023102
caller_token_teams = getattr(request.state, "token_teams", None)
3103+
# First-Party
31033104
from mcpgateway.services.caller_context import CallerContext # noqa: E402 pylint: disable=import-outside-toplevel
31043105

31053106
await server_service.register_server(
@@ -3258,6 +3259,7 @@ async def admin_edit_server(
32583259
)
32593260

32603261
caller_token_teams = getattr(request.state, "token_teams", None)
3262+
# First-Party
32613263
from mcpgateway.services.caller_context import CallerContext # noqa: E402 pylint: disable=import-outside-toplevel
32623264

32633265
await server_service.update_server(

mcpgateway/alembic/versions/3f7e9d1a2b4c_a2a_v1_domain_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def upgrade() -> None:
153153

154154
conn = op.get_bind()
155155
agents_with_auth = conn.execute(
156-
sa.text("SELECT id, auth_type, auth_value, auth_query_params " "FROM a2a_agents " "WHERE auth_type IS NOT NULL " "AND id NOT IN (SELECT a2a_agent_id FROM a2a_agent_auth)")
156+
sa.text("SELECT id, auth_type, auth_value, auth_query_params FROM a2a_agents WHERE auth_type IS NOT NULL AND id NOT IN (SELECT a2a_agent_id FROM a2a_agent_auth)")
157157
).fetchall()
158158
for agent in agents_with_auth:
159159
# auth_query_params may be a Python dict (from a JSON column);

mcpgateway/alembic/versions/77243f5bfce5_add_tool_id_to_a2a_agents.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ def upgrade() -> None:
4747

4848
# Fail if tools table doesn't exist - FK requires it
4949
if not inspector.has_table("tools"):
50-
raise RuntimeError(
51-
"Cannot proceed: a2a_agents table exists but tools table is missing. " "This migration adds a FK from a2a_agents.tool_id to tools.id. " "Please verify your database schema."
52-
)
50+
raise RuntimeError("Cannot proceed: a2a_agents table exists but tools table is missing. This migration adds a FK from a2a_agents.tool_id to tools.id. Please verify your database schema.")
5351

5452
# Check current state
5553
columns = [col["name"] for col in inspector.get_columns("a2a_agents")]
@@ -64,10 +62,10 @@ def upgrade() -> None:
6462
# If column exists but FK doesn't, check for orphaned references that would block FK creation
6563
if not need_column and need_fk:
6664
# Use COUNT for efficiency, then fetch limited sample for error message
67-
orphan_count = bind.execute(sa.text("SELECT COUNT(*) FROM a2a_agents WHERE tool_id IS NOT NULL " "AND tool_id NOT IN (SELECT id FROM tools)")).scalar() or 0
65+
orphan_count = bind.execute(sa.text("SELECT COUNT(*) FROM a2a_agents WHERE tool_id IS NOT NULL AND tool_id NOT IN (SELECT id FROM tools)")).scalar() or 0
6866
if orphan_count > 0:
6967
# Fetch limited sample for error details
70-
sample = bind.execute(sa.text("SELECT id, tool_id FROM a2a_agents WHERE tool_id IS NOT NULL " "AND tool_id NOT IN (SELECT id FROM tools) LIMIT 10")).fetchall()
68+
sample = bind.execute(sa.text("SELECT id, tool_id FROM a2a_agents WHERE tool_id IS NOT NULL AND tool_id NOT IN (SELECT id FROM tools) LIMIT 10")).fetchall()
7169
orphan_details = "\n".join(f" - agent {aid} -> tool {tid}" for aid, tid in sample)
7270
more_msg = f"\n ... and {orphan_count - len(sample)} more" if orphan_count > len(sample) else ""
7371
raise RuntimeError(

mcpgateway/alembic/versions/ba202ac1665f_migrate_user_roles_to_configurable_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _snapshot_config(bind, rev: str, values: dict) -> None:
7474
"""
7575
inspector = sa.inspect(bind)
7676
if "migration_metadata" not in inspector.get_table_names():
77-
logger.warning("migration_metadata table not found; skipping config snapshot. " "Downgrade will use live settings (non-hermetic).")
77+
logger.warning("migration_metadata table not found; skipping config snapshot. Downgrade will use live settings (non-hermetic).")
7878
return
7979
for key, value in values.items():
8080
bind.execute(
@@ -360,7 +360,7 @@ def downgrade() -> None:
360360
new_team_member_role = snapshot.get("default_team_member_role", settings.default_team_member_role)
361361
print(f" ✓ Loaded config snapshot from migration_metadata (revision={revision})")
362362
else:
363-
logger.warning("No config snapshot found in migration_metadata. " "Falling back to live settings — downgrade correctness depends on env vars matching upgrade time.")
363+
logger.warning("No config snapshot found in migration_metadata. Falling back to live settings — downgrade correctness depends on env vars matching upgrade time.")
364364
new_admin_role = settings.default_admin_role
365365
new_user_role = settings.default_user_role
366366
new_team_owner_role = settings.default_team_owner_role

mcpgateway/alembic/versions/f9a8b7c6d5e4_add_migration_metadata_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def downgrade() -> None:
7777

7878
count = bind.execute(text("SELECT COUNT(*) FROM migration_metadata")).scalar() or 0
7979
if count:
80-
raise RuntimeError(f"Cannot drop migration_metadata — {count} snapshot row(s) remain. " "Downgrade dependent migrations first (e.g., ba202ac1665f).")
80+
raise RuntimeError(f"Cannot drop migration_metadata — {count} snapshot row(s) remain. Downgrade dependent migrations first (e.g., ba202ac1665f).")
8181

8282
op.drop_table("migration_metadata")
8383
print(" ✓ Dropped migration_metadata table")

mcpgateway/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,9 +1331,7 @@ def _warn_if_rust_a2a_runtime_deprecated() -> None:
13311331
release).
13321332
"""
13331333
if getattr(settings, "experimental_rust_a2a_runtime_enabled", False):
1334-
logger.warning(
1335-
"EXPERIMENTAL_RUST_A2A_RUNTIME_ENABLED=true is DEPRECATED. " "The Rust A2A runtime is removed in the next release; " "Python dispatcher is the only path. This flag is now ignored."
1336-
)
1334+
logger.warning("EXPERIMENTAL_RUST_A2A_RUNTIME_ENABLED=true is DEPRECATED. The Rust A2A runtime is removed in the next release; Python dispatcher is the only path. This flag is now ignored.")
13371335

13381336

13391337
@asynccontextmanager
@@ -4169,6 +4167,7 @@ async def create_server(
41694167
team_id = team_id or token_team_id
41704168

41714169
logger.debug(f"User {SecurityValidator.sanitize_log_message(user_email)} is creating a new server for team {team_id}")
4170+
# First-Party
41724171
from mcpgateway.services.caller_context import CallerContext # noqa: E402 pylint: disable=import-outside-toplevel
41734172

41744173
result = await server_service.register_server(
@@ -4230,6 +4229,7 @@ async def update_server(
42304229

42314230
user_email: str = get_user_email(user)
42324231
caller_token_teams = getattr(request.state, "token_teams", None)
4232+
# First-Party
42334233
from mcpgateway.services.caller_context import CallerContext # noqa: E402 pylint: disable=import-outside-toplevel
42344234

42354235
result = await server_service.update_server(

mcpgateway/middleware/a2a_path_rewrite.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
reads the original path keeps its contract.
3737
"""
3838

39+
# Future
3940
from __future__ import annotations
4041

42+
# Standard
4143
import logging
4244
import re
4345

46+
# Third-Party
4447
from starlette.types import ASGIApp, Receive, Scope, Send
4548

4649
logger = logging.getLogger(__name__)

mcpgateway/services/a2a_access_policy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,22 @@
5151
module-load time (the service module imports this policy module).
5252
"""
5353

54+
# Future
5455
from __future__ import annotations
5556

56-
from typing import TYPE_CHECKING, List, Optional
57+
# Standard
58+
from typing import List, Optional, TYPE_CHECKING
5759

60+
# Third-Party
5861
from sqlalchemy.orm import Session
5962

63+
# First-Party
6064
from mcpgateway.db import Server as DbServer
6165
from mcpgateway.services.a2a_hooks import A2AAgentSnapshot
6266
from mcpgateway.services.a2a_server_service import _check_server_access
6367

6468
if TYPE_CHECKING: # pragma: no cover - import-time-only
69+
# First-Party
6570
from mcpgateway.services.a2a_service import A2AAgentService
6671

6772

mcpgateway/services/a2a_hooks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@
4242
is resolved — see ``docs/docs/architecture/a2a-cpex-hook-proposal.md``.
4343
"""
4444

45+
# Future
4546
from __future__ import annotations
4647

47-
import logging
48+
# Standard
4849
from dataclasses import dataclass, field
50+
import logging
4951
from typing import Any, Awaitable, Callable, Dict, List, Optional
5052

5153
logger = logging.getLogger(__name__)

mcpgateway/services/a2a_service.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@
3333
from mcpgateway.db import A2AAgent as DbA2AAgent
3434
from mcpgateway.db import A2AAgentMetric, A2AAgentMetricsHourly, A2ATask, EmailTeam
3535
from mcpgateway.db import EmailTeamMember as DbEmailTeamMember
36-
from mcpgateway.db import fresh_db_session, get_for_update, server_a2a_association
36+
from mcpgateway.db import fresh_db_session, get_for_update
3737
from mcpgateway.db import Server as DbServer
38+
from mcpgateway.db import server_a2a_association
3839
from mcpgateway.db import Tool as DbTool
40+
from mcpgateway.observability import create_span, set_span_attribute, set_span_error
41+
from mcpgateway.schemas import A2AAgentAggregateMetrics, A2AAgentCreate, A2AAgentMetrics, A2AAgentRead, A2AAgentUpdate
42+
from mcpgateway.schemas_a2a_native import AgentCapabilities, AgentCard, AgentSkill, SupportedInterface
3943
from mcpgateway.services.a2a_access_policy import (
4044
can_view_a2a_agent_directly,
4145
can_view_a2a_agent_in_server_context,
4246
)
43-
from mcpgateway.observability import create_span, set_span_attribute, set_span_error
44-
from mcpgateway.schemas import A2AAgentAggregateMetrics, A2AAgentCreate, A2AAgentMetrics, A2AAgentRead, A2AAgentUpdate
45-
from mcpgateway.schemas_a2a_native import AgentCapabilities, AgentCard, AgentSkill, SupportedInterface
4647
from mcpgateway.services.a2a_protocol import prepare_a2a_invocation
4748
from mcpgateway.services.base_service import BaseService
4849
from mcpgateway.services.encryption_service import protect_oauth_config_for_storage
@@ -1097,6 +1098,7 @@ async def resolve_agent_for_dispatch(
10971098
if not server:
10981099
raise AgentNotInServerError(agent_name, server_id)
10991100

1101+
# First-Party
11001102
from mcpgateway.services.a2a_hooks import A2AAgentSnapshot # pylint: disable=import-outside-toplevel
11011103

11021104
agent_snapshot = A2AAgentSnapshot.from_orm(agent)
@@ -1117,6 +1119,7 @@ async def resolve_agent_for_dispatch(
11171119
# to the centralized policy module. Visibility miss surfaces as
11181120
# A2AAgentNotFoundError per plan D11 / Oracle v2 #3 to prevent
11191121
# existence-leak side channels.
1122+
# First-Party
11201123
from mcpgateway.services.a2a_hooks import A2AAgentSnapshot # pylint: disable=import-outside-toplevel
11211124

11221125
agent_snapshot = A2AAgentSnapshot.from_orm(agent)
@@ -1212,6 +1215,7 @@ async def synthesize_agent_card(
12121215
if not agent:
12131216
return None
12141217

1218+
# First-Party
12151219
from mcpgateway.services.a2a_hooks import A2AAgentSnapshot # pylint: disable=import-outside-toplevel
12161220

12171221
agent_snapshot = A2AAgentSnapshot.from_orm(agent)

0 commit comments

Comments
 (0)