26 أسطر
699 B
Python
26 أسطر
699 B
Python
import json
|
|
from helpers import format_error, log
|
|
from api import api_list_issues
|
|
import httpx
|
|
|
|
|
|
def issue_list_tool(repo: str, state: str = "open") -> str:
|
|
try:
|
|
items = api_list_issues(
|
|
repo,
|
|
state if state in ("open", "closed", "all") else None
|
|
)
|
|
return json.dumps(
|
|
{
|
|
"status": "success",
|
|
"count": len(items),
|
|
"items": items
|
|
},
|
|
ensure_ascii=False
|
|
)
|
|
except httpx.HTTPStatusError as e:
|
|
return format_error("Issues list failed", e)
|
|
except Exception as e:
|
|
log.exception("Unexpected error while listing issues")
|
|
return f"{e}"
|