summaryrefslogtreecommitdiff
path: root/babel/localtime/_win32.py
diff options
context:
space:
mode:
Diffstat (limited to 'babel/localtime/_win32.py')
-rw-r--r--babel/localtime/_win32.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/babel/localtime/_win32.py b/babel/localtime/_win32.py
index a4f6d55..98d5170 100644
--- a/babel/localtime/_win32.py
+++ b/babel/localtime/_win32.py
@@ -1,23 +1,27 @@
+from __future__ import annotations
+
try:
import winreg
except ImportError:
winreg = None
-from babel.core import get_global
+from typing import Any, Dict, cast
+
import pytz
+from babel.core import get_global
# When building the cldr data on windows this module gets imported.
# Because at that point there is no global.dat yet this call will
# fail. We want to catch it down in that case then and just assume
# the mapping was empty.
try:
- tz_names = get_global('windows_zone_mapping')
+ tz_names: dict[str, str] = cast(Dict[str, str], get_global('windows_zone_mapping'))
except RuntimeError:
tz_names = {}
-def valuestodict(key):
+def valuestodict(key) -> dict[str, Any]:
"""Convert a registry key's values to a dictionary."""
dict = {}
size = winreg.QueryInfoKey(key)[1]
@@ -27,7 +31,7 @@ def valuestodict(key):
return dict
-def get_localzone_name():
+def get_localzone_name() -> str:
# Windows is special. It has unique time zone names (in several
# meanings of the word) available, but unfortunately, they can be
# translated to the language of the operating system, so we need to
@@ -86,7 +90,7 @@ def get_localzone_name():
return timezone
-def _get_localzone():
+def _get_localzone() -> pytz.BaseTzInfo:
if winreg is None:
raise pytz.UnknownTimeZoneError(
'Runtime support not available')