mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-15 18:25:18 +02:00
fix linting issues with ruff
This commit is contained in:
parent
063c272b98
commit
0c3e25a07b
4 changed files with 20 additions and 20 deletions
|
|
@ -5,17 +5,15 @@ Revises: ffd7445eb90a
|
||||||
Create Date: 2026-01-13 12:23:31.481643
|
Create Date: 2026-01-13 12:23:31.481643
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from typing import Sequence, Union
|
from collections.abc import Sequence
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = '5263aa4e7f94'
|
revision: str = '5263aa4e7f94'
|
||||||
down_revision: Union[str, None] = 'ffd7445eb90a'
|
down_revision: str | None = 'ffd7445eb90a'
|
||||||
branch_labels: Union[str, Sequence[str], None] = None
|
branch_labels: str | Sequence[str] | None = None
|
||||||
depends_on: Union[str, Sequence[str], None] = None
|
depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ This module provides a client for communicating with MCP servers via stdio trans
|
||||||
It handles server lifecycle management, tool discovery, and tool execution.
|
It handles server lifecycle management, tool discovery, and tool execution.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
|
|
@ -54,15 +53,17 @@ class MCPClient:
|
||||||
)
|
)
|
||||||
|
|
||||||
# Spawn server process and create session
|
# Spawn server process and create session
|
||||||
async with stdio_client(server=server_params) as (read, write):
|
async with (
|
||||||
async with ClientSession(read, write) as session:
|
stdio_client(server=server_params) as (read, write),
|
||||||
# Initialize the connection
|
ClientSession(read, write) as session,
|
||||||
await session.initialize()
|
):
|
||||||
self.session = session
|
# Initialize the connection
|
||||||
logger.info(
|
await session.initialize()
|
||||||
f"Connected to MCP server: {self.command} {' '.join(self.args)}"
|
self.session = session
|
||||||
)
|
logger.info(
|
||||||
yield session
|
f"Connected to MCP server: {self.command} {' '.join(self.args)}"
|
||||||
|
)
|
||||||
|
yield session
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to connect to MCP server: {e!s}", exc_info=True)
|
logger.error(f"Failed to connect to MCP server: {e!s}", exc_info=True)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ def _normalize_gemini_params(params: dict[str, Any], mcp_schema: dict[str, Any])
|
||||||
normalized_item[item_key] = item_value
|
normalized_item[item_key] = item_value
|
||||||
|
|
||||||
# Add missing required fields with empty defaults if needed
|
# Add missing required fields with empty defaults if needed
|
||||||
for required_field in items_properties.keys():
|
for required_field in items_properties:
|
||||||
if required_field not in normalized_item:
|
if required_field not in normalized_item:
|
||||||
# For arrays like observations, default to empty array
|
# For arrays like observations, default to empty array
|
||||||
if items_properties[required_field].get("type") == "array":
|
if items_properties[required_field].get("type") == "array":
|
||||||
|
|
@ -102,6 +102,7 @@ def _create_dynamic_input_model_from_schema(
|
||||||
# Use Any type for complex schemas to preserve structure
|
# Use Any type for complex schemas to preserve structure
|
||||||
# This allows the MCP server to do its own validation
|
# This allows the MCP server to do its own validation
|
||||||
from typing import Any as AnyType
|
from typing import Any as AnyType
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
if is_required:
|
if is_required:
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ from typing import Any
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from sqlalchemy import func
|
from sqlalchemy import select
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from sqlalchemy.future import select
|
from sqlalchemy.sql import func
|
||||||
|
|
||||||
from app.db import SearchSourceConnector, SearchSourceConnectorType
|
from app.db import SearchSourceConnector, SearchSourceConnectorType
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ def extract_identifier_from_credentials(
|
||||||
if ".atlassian.net" in hostname:
|
if ".atlassian.net" in hostname:
|
||||||
return hostname.replace(".atlassian.net", "")
|
return hostname.replace(".atlassian.net", "")
|
||||||
return hostname
|
return hostname
|
||||||
except Exception:
|
except (ValueError, TypeError, AttributeError):
|
||||||
pass
|
pass
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue