perf: wmo_to_russian использует модульную константу _WMO_MAPPING вместо создания dict при каждом вызове

This commit is contained in:
deadzilla 2026-07-11 23:56:54 +05:00
parent b22b02d65e
commit 49cb1a430b

View File

@ -90,9 +90,7 @@ async def fetch_open_meteo(
return None return None
def wmo_to_russian(code: Optional[int]) -> str: _WMO_MAPPING: dict[int, str] = {
"""Перевод WMO weather code в русский."""
mapping = {
0: "Ясно", 0: "Ясно",
1: "Ясно", 1: "Ясно",
2: "Переменная облачность", 2: "Переменная облачность",
@ -121,8 +119,12 @@ def wmo_to_russian(code: Optional[int]) -> str:
95: "Гроза", 95: "Гроза",
96: "Гроза с градом", 96: "Гроза с градом",
99: "Сильная гроза с градом", 99: "Сильная гроза с градом",
} }
return mapping.get(code, "Неизвестно")
def wmo_to_russian(code: Optional[int]) -> str:
"""Перевод WMO weather code в русский."""
return _WMO_MAPPING.get(code, "Неизвестно")
_WEATHER_MAPPING = [ _WEATHER_MAPPING = [