forked from HomeLab/unraid-mcp
lintfree
This commit is contained in:
@@ -1 +1 @@
|
||||
"""Core infrastructure components for Unraid MCP Server."""
|
||||
"""Core infrastructure components for Unraid MCP Server."""
|
||||
|
||||
@@ -81,7 +81,7 @@ async def make_graphql_request(
|
||||
"User-Agent": "UnraidMCPServer/0.1.0" # Custom user-agent
|
||||
}
|
||||
|
||||
payload = {"query": query}
|
||||
payload: dict[str, Any] = {"query": query}
|
||||
if variables:
|
||||
payload["variables"] = variables
|
||||
|
||||
@@ -119,17 +119,18 @@ async def make_graphql_request(
|
||||
raise ToolError(f"GraphQL API error: {error_details}")
|
||||
|
||||
logger.debug("GraphQL request successful.")
|
||||
return response_data.get("data", {}) # Return only the data part
|
||||
data = response_data.get("data", {})
|
||||
return data if isinstance(data, dict) else {} # Ensure we return dict
|
||||
|
||||
except httpx.HTTPStatusError as e:
|
||||
logger.error(f"HTTP error occurred: {e.response.status_code} - {e.response.text}")
|
||||
raise ToolError(f"HTTP error {e.response.status_code}: {e.response.text}")
|
||||
raise ToolError(f"HTTP error {e.response.status_code}: {e.response.text}") from e
|
||||
except httpx.RequestError as e:
|
||||
logger.error(f"Request error occurred: {e}")
|
||||
raise ToolError(f"Network connection error: {str(e)}")
|
||||
raise ToolError(f"Network connection error: {str(e)}") from e
|
||||
except json.JSONDecodeError as e:
|
||||
logger.error(f"Failed to decode JSON response: {e}")
|
||||
raise ToolError(f"Invalid JSON response from Unraid API: {str(e)}")
|
||||
raise ToolError(f"Invalid JSON response from Unraid API: {str(e)}") from e
|
||||
|
||||
|
||||
def get_timeout_for_operation(operation_type: str = "default") -> httpx.Timeout:
|
||||
|
||||
@@ -6,13 +6,13 @@ multiple modules for consistent data handling.
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass
|
||||
class SubscriptionData:
|
||||
"""Container for subscription data with metadata."""
|
||||
data: Dict[str, Any]
|
||||
data: dict[str, Any]
|
||||
last_updated: datetime
|
||||
subscription_type: str
|
||||
|
||||
@@ -24,20 +24,20 @@ class SystemHealth:
|
||||
issues: list[str]
|
||||
warnings: list[str]
|
||||
last_checked: datetime
|
||||
component_status: Dict[str, str]
|
||||
component_status: dict[str, str]
|
||||
|
||||
|
||||
@dataclass
|
||||
class APIResponse:
|
||||
"""Container for standardized API response data."""
|
||||
success: bool
|
||||
data: Optional[Dict[str, Any]] = None
|
||||
error: Optional[str] = None
|
||||
metadata: Optional[Dict[str, Any]] = None
|
||||
data: dict[str, Any] | None = None
|
||||
error: str | None = None
|
||||
metadata: dict[str, Any] | None = None
|
||||
|
||||
|
||||
# Type aliases for common data structures
|
||||
ConfigValue = Union[str, int, bool, float, None]
|
||||
ConfigDict = Dict[str, ConfigValue]
|
||||
GraphQLVariables = Dict[str, Any]
|
||||
HealthStatus = Dict[str, Union[str, bool, int, list]]
|
||||
ConfigValue = str | int | bool | float | None
|
||||
ConfigDict = dict[str, ConfigValue]
|
||||
GraphQLVariables = dict[str, Any]
|
||||
HealthStatus = dict[str, str | bool | int | list[Any]]
|
||||
|
||||
Reference in New Issue
Block a user