Skip to content

Commit 2e2106c

Browse files
authored
Massive isort (#242)
Signed-off-by: Mihai Criveti <[email protected]>
1 parent ba526b8 commit 2e2106c

Some content is hidden

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

48 files changed

+190
-188
lines changed

alembic/env.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# Standard
33
from logging.config import fileConfig
44

5+
# Third-Party
6+
from sqlalchemy import engine_from_config, pool
7+
58
# First-Party
69
from alembic import context
710
from mcpgateway.config import settings
811

9-
# Third-Party
10-
from sqlalchemy import engine_from_config, pool
11-
1212
# from mcpgateway.db import get_metadata
1313
# target_metadata = get_metadata()
1414

alembic/versions/b77ca9d2de7e_uuid_pk_and_slug_refactor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
from typing import Sequence, Union
1111
import uuid
1212

13+
# Third-Party
14+
import sqlalchemy as sa
15+
from sqlalchemy.orm import Session
16+
1317
# First-Party
1418
from alembic import op
1519
from mcpgateway.config import settings
1620
from mcpgateway.utils.create_slug import slugify
1721

18-
# Third-Party
19-
import sqlalchemy as sa
20-
from sqlalchemy.orm import Session
21-
2222
# revision identifiers, used by Alembic.
2323
revision: str = 'b77ca9d2de7e'
2424
down_revision: Union[str, Sequence[str], None] = None

alembic/versions/e4fc04d1a442_add_annotations_to_tables.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
# Standard
1010
from typing import Sequence, Union
1111

12-
# First-Party
13-
from alembic import op
14-
1512
# Third-Party
1613
import sqlalchemy as sa
1714
from sqlalchemy.orm import Session
1815

16+
# First-Party
17+
from alembic import op
18+
1919
# revision identifiers, used by Alembic.
2020
revision: str = 'e4fc04d1a442'
2121
down_revision: Union[str, Sequence[str], None] = 'b77ca9d2de7e'
@@ -52,9 +52,9 @@ def downgrade() -> None:
5252
bind = op.get_bind()
5353
sess = Session(bind=bind)
5454
inspector = sa.inspect(bind)
55-
55+
5656
if not inspector.has_table("gateways"):
5757
print("Fresh database detected. Skipping migration.")
5858
return
59-
59+
6060
op.drop_column('tools', 'annotations')
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
# -*- coding: utf-8 -*-
12
"""Add enabled and reachable columns in tools and gateways tables and migrate data (is_active ➜ enabled,reachable).
23
34
Revision ID: e75490e949b1
45
Revises: e4fc04d1a442
5-
Create Date: 2025‑07‑02 17:12:40.678256
6+
Create Date: 2025‑07‑02 17:12:40.678256
67
"""
78

89
# Standard
910
from typing import Sequence, Union
1011

12+
# Third-Party
13+
import sqlalchemy as sa
14+
1115
# First-Party
1216
# Alembic / SQLAlchemy
1317
from alembic import op
1418

15-
# Third-Party
16-
import sqlalchemy as sa
17-
1819
# Revision identifiers.
1920
revision: str = "e75490e949b1"
2021
down_revision: Union[str, Sequence[str], None] = "e4fc04d1a442"
@@ -24,7 +25,7 @@
2425

2526
def upgrade():
2627
"""
27-
Renames 'is_active' to 'enabled' and adds a new 'reachable' column (default True)
28+
Renames 'is_active' to 'enabled' and adds a new 'reachable' column (default True)
2829
in both 'tools' and 'gateways' tables.
2930
"""
3031
op.alter_column('tools', 'is_active', new_column_name='enabled')
@@ -36,11 +37,11 @@ def upgrade():
3637

3738
def downgrade():
3839
"""
39-
Reverts the changes by renaming 'enabled' back to 'is_active'
40+
Reverts the changes by renaming 'enabled' back to 'is_active'
4041
and dropping the 'reachable' column in both 'tools' and 'gateways' tables.
4142
"""
4243
op.alter_column('tools', 'enabled', new_column_name='is_active')
4344
op.drop_column('tools', 'reachable')
4445

4546
op.alter_column('gateways', 'enabled', new_column_name='is_active')
46-
op.drop_column('gateways', 'reachable')
47+
op.drop_column('gateways', 'reachable')

mcpgateway/bootstrap_db.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
# -*- coding: utf-8 -*-
12
# mcpgateway/bootstrap_db.py
23
# Standard
34
import asyncio
45
import logging
56
from pathlib import Path
67

8+
# Third-Party
9+
from sqlalchemy import create_engine, inspect
10+
711
# First-Party
812
from alembic import command
913
from alembic.config import Config
1014
from mcpgateway.config import settings
1115
from mcpgateway.db import Base
1216

13-
# Third-Party
14-
from sqlalchemy import create_engine, inspect
15-
1617
logger = logging.getLogger(__name__)
1718

1819

mcpgateway/cache/session_registry.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
import time
1717
from typing import Any, Dict, Optional
1818

19+
# Third-Party
20+
from fastapi import HTTPException, status
21+
import httpx
22+
1923
# First-Party
2024
from mcpgateway.config import settings
2125
from mcpgateway.db import get_db, SessionMessageRecord, SessionRecord
2226
from mcpgateway.services import PromptService, ResourceService, ToolService
2327
from mcpgateway.transports import SSETransport
2428
from mcpgateway.types import Implementation, InitializeResult, ServerCapabilities
2529

26-
# Third-Party
27-
from fastapi import HTTPException, status
28-
import httpx
29-
3030
logger = logging.getLogger(__name__)
3131

3232
tool_service = ToolService()

mcpgateway/db.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
from typing import Any, Dict, List, Optional
2222
import uuid
2323

24-
# First-Party
25-
from mcpgateway.config import settings
26-
from mcpgateway.types import ResourceContent
27-
from mcpgateway.utils.create_slug import slugify
28-
from mcpgateway.utils.db_isready import wait_for_db_ready
29-
3024
# Third-Party
3125
import jsonschema
3226
from sqlalchemy import (
@@ -59,6 +53,12 @@
5953
)
6054
from sqlalchemy.orm.attributes import get_history
6155

56+
# First-Party
57+
from mcpgateway.config import settings
58+
from mcpgateway.types import ResourceContent
59+
from mcpgateway.utils.create_slug import slugify
60+
from mcpgateway.utils.db_isready import wait_for_db_ready
61+
6262
# ---------------------------------------------------------------------------
6363
# 1. Parse the URL so we can inspect backend ("postgresql", "sqlite", …)
6464
# and the specific driver ("psycopg2", "asyncpg", empty string = default).

mcpgateway/handlers/sampling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
# First-Party
2020
from mcpgateway.types import CreateMessageResult, ModelPreferences, Role, TextContent
2121

22-
2322
logger = logging.getLogger(__name__)
2423

2524

mcpgateway/main.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,28 @@
3232
import logging
3333
from typing import Any, AsyncIterator, Dict, List, Optional, Union
3434

35+
# Third-Party
36+
from fastapi import (
37+
APIRouter,
38+
Body,
39+
Depends,
40+
FastAPI,
41+
HTTPException,
42+
Request,
43+
status,
44+
WebSocket,
45+
WebSocketDisconnect,
46+
)
47+
from fastapi.background import BackgroundTasks
48+
from fastapi.middleware.cors import CORSMiddleware
49+
from fastapi.responses import JSONResponse, RedirectResponse, StreamingResponse
50+
from fastapi.staticfiles import StaticFiles
51+
from fastapi.templating import Jinja2Templates
52+
import httpx
53+
from sqlalchemy import text
54+
from sqlalchemy.orm import Session
55+
from starlette.middleware.base import BaseHTTPMiddleware
56+
3557
# First-Party
3658
from mcpgateway import __version__
3759
from mcpgateway.admin import admin_router
@@ -109,28 +131,6 @@
109131
# Import the admin routes from the new module
110132
from mcpgateway.version import router as version_router
111133

112-
# Third-Party
113-
from fastapi import (
114-
APIRouter,
115-
Body,
116-
Depends,
117-
FastAPI,
118-
HTTPException,
119-
Request,
120-
status,
121-
WebSocket,
122-
WebSocketDisconnect,
123-
)
124-
from fastapi.background import BackgroundTasks
125-
from fastapi.middleware.cors import CORSMiddleware
126-
from fastapi.responses import JSONResponse, RedirectResponse, StreamingResponse
127-
from fastapi.staticfiles import StaticFiles
128-
from fastapi.templating import Jinja2Templates
129-
import httpx
130-
from sqlalchemy import text
131-
from sqlalchemy.orm import Session
132-
from starlette.middleware.base import BaseHTTPMiddleware
133-
134134
# Initialize logging service first
135135
logging_service = LoggingService()
136136
logger = logging_service.get_logger("mcpgateway")

mcpgateway/services/gateway_service.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
from typing import Any, AsyncGenerator, Dict, List, Optional, Set
2222
import uuid
2323

24+
# Third-Party
25+
from filelock import FileLock, Timeout
26+
import httpx
27+
from mcp import ClientSession
28+
from mcp.client.sse import sse_client
29+
from mcp.client.streamable_http import streamablehttp_client
30+
from sqlalchemy import select
31+
from sqlalchemy.orm import Session
32+
2433
# First-Party
2534
from mcpgateway.config import settings
2635
from mcpgateway.db import Gateway as DbGateway
@@ -31,15 +40,6 @@
3140
from mcpgateway.utils.create_slug import slugify
3241
from mcpgateway.utils.services_auth import decode_auth
3342

34-
# Third-Party
35-
from filelock import FileLock, Timeout
36-
import httpx
37-
from mcp import ClientSession
38-
from mcp.client.sse import sse_client
39-
from mcp.client.streamable_http import streamablehttp_client
40-
from sqlalchemy import select
41-
from sqlalchemy.orm import Session
42-
4343
try:
4444
# Third-Party
4545
import redis

0 commit comments

Comments
 (0)