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
def wmo_to_russian(code: Optional[int]) -> str:
"""Перевод WMO weather code в русский."""
mapping = {
_WMO_MAPPING: dict[int, str] = {
0: "Ясно",
1: "Ясно",
2: "Переменная облачность",
@ -122,7 +120,11 @@ def wmo_to_russian(code: Optional[int]) -> str:
96: "Гроза с градом",
99: "Сильная гроза с градом",
}
return mapping.get(code, "Неизвестно")
def wmo_to_russian(code: Optional[int]) -> str:
"""Перевод WMO weather code в русский."""
return _WMO_MAPPING.get(code, "Неизвестно")
_WEATHER_MAPPING = [