/
ksilisk
/
spbtechrun_hack
Обзор
Документация
Войти
/
ksilisk
/
spbtechrun_hack
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
python/mcp/sportgrounds_client.py
39 строк
1 KB
Shaliko Salimov
fixed api clients
05 дек 2025, 21:03
05 дек 2025, 21:03
f536349
Код
Авторство
О чём код?
from __future__ import annotations from typing import Any from base_client import YazzhBaseClient from mappers import map_sportgrounds from yazzh import Sportground class SportgroundsClient(YazzhBaseClient): """Клиент спортплощадок (/sportgrounds/*).""" async def list_grounds( self, *, district: str | None = None, season: str | None = None, light: str | None = None, page: int = 1, count: int = 3, ) -> list[Sportground]: params: dict[str, Any] = { "page": page, "count": count, } if district is not None and district != '': params['district'] = district if season is not None and season != '': params['season'] = season if light is not None and light != '': params['light'] = light try: payload = await self._get("/sportgrounds/", params=params) except Exception as exc: # On connectivity issues return an empty list so MCP tool does not fail hard. # The exception details are still logged by the caller. print(f"[sportgrounds_client] fallback to empty list due to error: {exc}") return [] return map_sportgrounds(payload)