chore: fix all ruff lint errors + format — 0 errors, 306 tests pass
This commit is contained in:
+24
-7
@@ -1,13 +1,30 @@
|
||||
"""Pydantic schemas package."""
|
||||
|
||||
from app.schemas.plugin import PluginInfo, PluginListResponse, PluginActionResponse, PluginUninstallResponse
|
||||
from app.schemas.ai_copilot import (
|
||||
CopilotQueryRequest, CopilotAction, CopilotQueryResponse,
|
||||
CopilotExecuteRequest, CopilotExecuteResponse,
|
||||
CopilotHistoryResponse, CopilotMessageResponse,
|
||||
CopilotAction, # noqa: F401
|
||||
CopilotExecuteRequest, # noqa: F401
|
||||
CopilotExecuteResponse, # noqa: F401
|
||||
CopilotHistoryResponse, # noqa: F401
|
||||
CopilotMessageResponse, # noqa: F401
|
||||
CopilotQueryRequest, # noqa: F401
|
||||
CopilotQueryResponse, # noqa: F401
|
||||
)
|
||||
from app.schemas.plugin import (
|
||||
PluginActionResponse, # noqa: F401
|
||||
PluginInfo, # noqa: F401
|
||||
PluginListResponse, # noqa: F401
|
||||
PluginUninstallResponse, # noqa: F401
|
||||
)
|
||||
from app.schemas.workflow import (
|
||||
WorkflowCreate, WorkflowUpdate, WorkflowResponse, WorkflowListResponse,
|
||||
InstanceCreate, InstanceResponse, InstanceDetailResponse, InstanceListResponse,
|
||||
AdvanceRequest, StepHistoryResponse, WorkflowStep,
|
||||
AdvanceRequest, # noqa: F401
|
||||
InstanceCreate, # noqa: F401
|
||||
InstanceDetailResponse, # noqa: F401
|
||||
InstanceListResponse, # noqa: F401
|
||||
InstanceResponse, # noqa: F401
|
||||
StepHistoryResponse, # noqa: F401
|
||||
WorkflowCreate, # noqa: F401
|
||||
WorkflowListResponse, # noqa: F401
|
||||
WorkflowResponse, # noqa: F401
|
||||
WorkflowStep, # noqa: F401
|
||||
WorkflowUpdate, # noqa: F401
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ from pydantic import BaseModel, Field
|
||||
|
||||
class CopilotQueryRequest(BaseModel):
|
||||
"""Natural language query to the AI copilot."""
|
||||
|
||||
query: str = Field(..., min_length=1, max_length=2000)
|
||||
conversation_id: str | None = None
|
||||
context: dict = Field(default_factory=dict)
|
||||
@@ -14,6 +15,7 @@ class CopilotQueryRequest(BaseModel):
|
||||
|
||||
class CopilotAction(BaseModel):
|
||||
"""A proposed API action derived from NL input."""
|
||||
|
||||
method: str = Field(..., pattern="^(GET|POST|PATCH|DELETE)$")
|
||||
path: str = Field(..., min_length=1)
|
||||
body: dict | None = None
|
||||
@@ -23,6 +25,7 @@ class CopilotAction(BaseModel):
|
||||
|
||||
class CopilotQueryResponse(BaseModel):
|
||||
"""Response from copilot query — proposed actions for user confirmation."""
|
||||
|
||||
conversation_id: str
|
||||
message: str
|
||||
proposed_actions: list[CopilotAction] = Field(default_factory=list)
|
||||
@@ -30,12 +33,14 @@ class CopilotQueryResponse(BaseModel):
|
||||
|
||||
class CopilotExecuteRequest(BaseModel):
|
||||
"""Execute a proposed action after user confirmation."""
|
||||
|
||||
conversation_id: str
|
||||
action: CopilotAction
|
||||
|
||||
|
||||
class CopilotExecuteResponse(BaseModel):
|
||||
"""Result of executing a proposed action."""
|
||||
|
||||
conversation_id: str
|
||||
success: bool
|
||||
status_code: int
|
||||
@@ -45,6 +50,7 @@ class CopilotExecuteResponse(BaseModel):
|
||||
|
||||
class CopilotMessageResponse(BaseModel):
|
||||
"""A single message in conversation history."""
|
||||
|
||||
id: str
|
||||
role: str
|
||||
content: str
|
||||
@@ -56,6 +62,7 @@ class CopilotMessageResponse(BaseModel):
|
||||
|
||||
class CopilotHistoryResponse(BaseModel):
|
||||
"""Paginated conversation history."""
|
||||
|
||||
items: list[CopilotMessageResponse]
|
||||
total: int
|
||||
page: int
|
||||
|
||||
@@ -37,7 +37,9 @@ class PluginActionResponse(BaseModel):
|
||||
status: str
|
||||
installed: bool = False
|
||||
active: bool = False
|
||||
dropped_tables: list[str] = Field(default_factory=list, description="Tables dropped (uninstall with remove_data=true)")
|
||||
dropped_tables: list[str] = Field(
|
||||
default_factory=list, description="Tables dropped (uninstall with remove_data=true)"
|
||||
)
|
||||
message: str = ""
|
||||
|
||||
|
||||
@@ -49,6 +51,7 @@ class PluginUninstallResponse(PluginActionResponse):
|
||||
|
||||
class ManifestFieldDoc(BaseModel):
|
||||
"""Documentation for a single manifest field."""
|
||||
|
||||
type: str
|
||||
required: str
|
||||
description: str
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from pydantic import BaseModel, Field
|
||||
|
||||
class WorkflowStep(BaseModel):
|
||||
"""A single step in a workflow definition."""
|
||||
|
||||
name: str = Field(..., min_length=1, max_length=200)
|
||||
type: str = Field(..., pattern="^(action|approval|notification|condition)$")
|
||||
config: dict = Field(default_factory=dict)
|
||||
@@ -15,6 +16,7 @@ class WorkflowStep(BaseModel):
|
||||
|
||||
class WorkflowCreate(BaseModel):
|
||||
"""Create a new workflow definition."""
|
||||
|
||||
name: str = Field(..., min_length=1, max_length=200)
|
||||
description: str | None = None
|
||||
trigger_event: str | None = None
|
||||
@@ -24,6 +26,7 @@ class WorkflowCreate(BaseModel):
|
||||
|
||||
class WorkflowUpdate(BaseModel):
|
||||
"""Update an existing workflow definition."""
|
||||
|
||||
name: str | None = Field(None, max_length=200)
|
||||
description: str | None = None
|
||||
trigger_event: str | None = None
|
||||
@@ -33,6 +36,7 @@ class WorkflowUpdate(BaseModel):
|
||||
|
||||
class WorkflowResponse(BaseModel):
|
||||
"""Workflow definition response."""
|
||||
|
||||
id: str
|
||||
name: str
|
||||
description: str | None = None
|
||||
@@ -46,6 +50,7 @@ class WorkflowResponse(BaseModel):
|
||||
|
||||
class WorkflowListResponse(BaseModel):
|
||||
"""Paginated workflow list."""
|
||||
|
||||
items: list[WorkflowResponse]
|
||||
total: int
|
||||
page: int
|
||||
@@ -54,12 +59,14 @@ class WorkflowListResponse(BaseModel):
|
||||
|
||||
class InstanceCreate(BaseModel):
|
||||
"""Create a new workflow instance."""
|
||||
|
||||
context: dict = Field(default_factory=dict)
|
||||
timeout_hours: int | None = None
|
||||
|
||||
|
||||
class InstanceResponse(BaseModel):
|
||||
"""Workflow instance response with current state and history."""
|
||||
|
||||
id: str
|
||||
workflow_id: str
|
||||
status: str
|
||||
@@ -75,12 +82,14 @@ class InstanceResponse(BaseModel):
|
||||
|
||||
class InstanceDetailResponse(InstanceResponse):
|
||||
"""Instance with step history."""
|
||||
|
||||
history: list[dict] = Field(default_factory=list)
|
||||
workflow_name: str | None = None
|
||||
|
||||
|
||||
class InstanceListResponse(BaseModel):
|
||||
"""Paginated instance list."""
|
||||
|
||||
items: list[InstanceResponse]
|
||||
total: int
|
||||
page: int
|
||||
@@ -89,12 +98,14 @@ class InstanceListResponse(BaseModel):
|
||||
|
||||
class AdvanceRequest(BaseModel):
|
||||
"""Advance or reject a workflow instance step."""
|
||||
|
||||
decision: str = Field(..., pattern="^(approve|reject)$")
|
||||
comment: str | None = None
|
||||
|
||||
|
||||
class StepHistoryResponse(BaseModel):
|
||||
"""Step history entry."""
|
||||
|
||||
id: str
|
||||
instance_id: str
|
||||
step_index: int
|
||||
|
||||
Reference in New Issue
Block a user