perf: wmo_to_russian использует модульную константу _WMO_MAPPING вместо создания dict при каждом вызове
This commit is contained in:
parent
b22b02d65e
commit
49cb1a430b
@ -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: "Переменная облачность",
|
||||
@ -121,8 +119,12 @@ def wmo_to_russian(code: Optional[int]) -> str:
|
||||
95: "Гроза",
|
||||
96: "Гроза с градом",
|
||||
99: "Сильная гроза с градом",
|
||||
}
|
||||
return mapping.get(code, "Неизвестно")
|
||||
}
|
||||
|
||||
|
||||
def wmo_to_russian(code: Optional[int]) -> str:
|
||||
"""Перевод WMO weather code в русский."""
|
||||
return _WMO_MAPPING.get(code, "Неизвестно")
|
||||
|
||||
|
||||
_WEATHER_MAPPING = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user