chore(backend): standardize multiline formatting across modules
Reformatted multiline function calls, object definitions, and queries for improved code readability and consistency. Adjusted imports and constraints where necessary.
This commit is contained in:
@@ -32,9 +32,7 @@ api_router.include_router(
|
||||
api_router.include_router(events.router, tags=["Events"])
|
||||
|
||||
# Syndarix domain routers
|
||||
api_router.include_router(
|
||||
projects.router, prefix="/projects", tags=["Projects"]
|
||||
)
|
||||
api_router.include_router(projects.router, prefix="/projects", tags=["Projects"])
|
||||
api_router.include_router(
|
||||
agent_types.router, prefix="/agent-types", tags=["Agent Types"]
|
||||
)
|
||||
|
||||
@@ -57,8 +57,18 @@ RATE_MULTIPLIER = 100 if IS_TEST else 1
|
||||
# Valid status transitions for agent lifecycle management
|
||||
VALID_STATUS_TRANSITIONS: dict[AgentStatus, set[AgentStatus]] = {
|
||||
AgentStatus.IDLE: {AgentStatus.WORKING, AgentStatus.PAUSED, AgentStatus.TERMINATED},
|
||||
AgentStatus.WORKING: {AgentStatus.IDLE, AgentStatus.WAITING, AgentStatus.PAUSED, AgentStatus.TERMINATED},
|
||||
AgentStatus.WAITING: {AgentStatus.IDLE, AgentStatus.WORKING, AgentStatus.PAUSED, AgentStatus.TERMINATED},
|
||||
AgentStatus.WORKING: {
|
||||
AgentStatus.IDLE,
|
||||
AgentStatus.WAITING,
|
||||
AgentStatus.PAUSED,
|
||||
AgentStatus.TERMINATED,
|
||||
},
|
||||
AgentStatus.WAITING: {
|
||||
AgentStatus.IDLE,
|
||||
AgentStatus.WORKING,
|
||||
AgentStatus.PAUSED,
|
||||
AgentStatus.TERMINATED,
|
||||
},
|
||||
AgentStatus.PAUSED: {AgentStatus.IDLE, AgentStatus.TERMINATED},
|
||||
AgentStatus.TERMINATED: set(), # Terminal state, no transitions allowed
|
||||
}
|
||||
@@ -870,9 +880,7 @@ async def terminate_agent(
|
||||
agent_name = agent.name
|
||||
|
||||
# Terminate the agent
|
||||
terminated_agent = await agent_instance_crud.terminate(
|
||||
db, instance_id=agent_id
|
||||
)
|
||||
terminated_agent = await agent_instance_crud.terminate(db, instance_id=agent_id)
|
||||
|
||||
if not terminated_agent:
|
||||
raise NotFoundError(
|
||||
@@ -881,8 +889,7 @@ async def terminate_agent(
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"User {current_user.email} terminated agent {agent_name} "
|
||||
f"(id={agent_id})"
|
||||
f"User {current_user.email} terminated agent {agent_name} (id={agent_id})"
|
||||
)
|
||||
|
||||
return MessageResponse(
|
||||
|
||||
@@ -199,7 +199,9 @@ async def stream_project_events(
|
||||
project_id: UUID,
|
||||
db: "AsyncSession" = Depends(get_db),
|
||||
event_bus: EventBus = Depends(get_event_bus),
|
||||
token: str | None = Query(None, description="Auth token (for EventSource compatibility)"),
|
||||
token: str | None = Query(
|
||||
None, description="Auth token (for EventSource compatibility)"
|
||||
),
|
||||
authorization: str | None = Header(None, alias="Authorization"),
|
||||
last_event_id: str | None = Header(None, alias="Last-Event-ID"),
|
||||
):
|
||||
|
||||
@@ -278,9 +278,7 @@ async def list_issues(
|
||||
assigned_agent_id: UUID | None = Query(
|
||||
None, description="Filter by assigned agent ID"
|
||||
),
|
||||
sync_status: SyncStatus | None = Query(
|
||||
None, description="Filter by sync status"
|
||||
),
|
||||
sync_status: SyncStatus | None = Query(None, description="Filter by sync status"),
|
||||
search: str | None = Query(
|
||||
None, min_length=1, max_length=100, description="Search in title and body"
|
||||
),
|
||||
@@ -783,9 +781,7 @@ async def assign_issue(
|
||||
updated_issue = await issue_crud.assign_to_agent(
|
||||
db, issue_id=issue_id, agent_id=None
|
||||
)
|
||||
logger.info(
|
||||
f"User {current_user.email} unassigned issue {issue_id}"
|
||||
)
|
||||
logger.info(f"User {current_user.email} unassigned issue {issue_id}")
|
||||
|
||||
if not updated_issue:
|
||||
raise NotFoundError(
|
||||
|
||||
@@ -197,10 +197,10 @@ async def list_projects(
|
||||
status_filter: ProjectStatus | None = Query(
|
||||
None, alias="status", description="Filter by project status"
|
||||
),
|
||||
search: str | None = Query(None, description="Search by name, slug, or description"),
|
||||
all_projects: bool = Query(
|
||||
False, description="Show all projects (superuser only)"
|
||||
search: str | None = Query(
|
||||
None, description="Search by name, slug, or description"
|
||||
),
|
||||
all_projects: bool = Query(False, description="Show all projects (superuser only)"),
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> Any:
|
||||
@@ -212,7 +212,9 @@ async def list_projects(
|
||||
"""
|
||||
try:
|
||||
# Determine owner filter based on user role and request
|
||||
owner_id = None if (current_user.is_superuser and all_projects) else current_user.id
|
||||
owner_id = (
|
||||
None if (current_user.is_superuser and all_projects) else current_user.id
|
||||
)
|
||||
|
||||
projects_data, total = await project_crud.get_multi_with_counts(
|
||||
db,
|
||||
@@ -379,13 +381,15 @@ async def update_project(
|
||||
_check_project_ownership(project, current_user)
|
||||
|
||||
# Update the project
|
||||
updated_project = await project_crud.update(db, db_obj=project, obj_in=project_in)
|
||||
logger.info(
|
||||
f"User {current_user.email} updated project {updated_project.slug}"
|
||||
updated_project = await project_crud.update(
|
||||
db, db_obj=project, obj_in=project_in
|
||||
)
|
||||
logger.info(f"User {current_user.email} updated project {updated_project.slug}")
|
||||
|
||||
# Get updated project with counts
|
||||
project_data = await project_crud.get_with_counts(db, project_id=updated_project.id)
|
||||
project_data = await project_crud.get_with_counts(
|
||||
db, project_id=updated_project.id
|
||||
)
|
||||
|
||||
if not project_data:
|
||||
# This shouldn't happen, but handle gracefully
|
||||
@@ -551,7 +555,9 @@ async def pause_project(
|
||||
logger.info(f"User {current_user.email} paused project {project.slug}")
|
||||
|
||||
# Get project with counts
|
||||
project_data = await project_crud.get_with_counts(db, project_id=updated_project.id)
|
||||
project_data = await project_crud.get_with_counts(
|
||||
db, project_id=updated_project.id
|
||||
)
|
||||
|
||||
if not project_data:
|
||||
raise NotFoundError(
|
||||
@@ -634,7 +640,9 @@ async def resume_project(
|
||||
logger.info(f"User {current_user.email} resumed project {project.slug}")
|
||||
|
||||
# Get project with counts
|
||||
project_data = await project_crud.get_with_counts(db, project_id=updated_project.id)
|
||||
project_data = await project_crud.get_with_counts(
|
||||
db, project_id=updated_project.id
|
||||
)
|
||||
|
||||
if not project_data:
|
||||
raise NotFoundError(
|
||||
|
||||
@@ -320,7 +320,9 @@ async def list_sprints(
|
||||
return PaginatedResponse(data=sprint_responses, pagination=pagination_meta)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error listing sprints for project {project_id}: {e!s}", exc_info=True)
|
||||
logger.error(
|
||||
f"Error listing sprints for project {project_id}: {e!s}", exc_info=True
|
||||
)
|
||||
raise
|
||||
|
||||
|
||||
@@ -564,7 +566,9 @@ async def update_sprint(
|
||||
)
|
||||
|
||||
# Update the sprint
|
||||
updated_sprint = await sprint_crud.update(db, db_obj=sprint, obj_in=sprint_update)
|
||||
updated_sprint = await sprint_crud.update(
|
||||
db, db_obj=sprint, obj_in=sprint_update
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"User {current_user.id} updated sprint {sprint_id} in project {project_id}"
|
||||
@@ -1123,7 +1127,9 @@ async def remove_issue_from_sprint(
|
||||
request: Request,
|
||||
project_id: UUID,
|
||||
sprint_id: UUID,
|
||||
issue_id: UUID = Query(..., description="ID of the issue to remove from the sprint"),
|
||||
issue_id: UUID = Query(
|
||||
..., description="ID of the issue to remove from the sprint"
|
||||
),
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> Any:
|
||||
|
||||
Reference in New Issue
Block a user