Skip to content

Commit 6c8b3d3

Browse files
committed
More localtime annotations
1 parent 90032bf commit 6c8b3d3

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

babel/localtime/_unix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytz
44

55

6-
def _tz_from_env(tzenv):
6+
def _tz_from_env(tzenv: str) -> pytz.BaseTzInfo:
77
if tzenv[0] == ':':
88
tzenv = tzenv[1:]
99

@@ -23,7 +23,7 @@ def _tz_from_env(tzenv):
2323
"Please use a timezone in the form of Continent/City")
2424

2525

26-
def _get_localzone(_root='/'):
26+
def _get_localzone(_root: str = '/') -> pytz.BaseTzInfo:
2727
"""Tries to find the local timezone configuration.
2828
This method prefers finding the timezone name and passing that to pytz,
2929
over passing in the localtime file, as in the later case the zoneinfo

babel/localtime/_win32.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
except ImportError:
44
winreg = None
55

6-
from babel.core import get_global
6+
from __future__ import annotations
7+
8+
from typing import Dict, cast
9+
710
import pytz
811

12+
from babel.core import get_global
913

1014
# When building the cldr data on windows this module gets imported.
1115
# Because at that point there is no global.dat yet this call will
1216
# fail. We want to catch it down in that case then and just assume
1317
# the mapping was empty.
1418
try:
15-
tz_names = get_global('windows_zone_mapping')
19+
tz_names: dict[str, str] = cast(Dict[str, str], get_global('windows_zone_mapping'))
1620
except RuntimeError:
1721
tz_names = {}
1822

@@ -27,7 +31,7 @@ def valuestodict(key):
2731
return dict
2832

2933

30-
def get_localzone_name():
34+
def get_localzone_name() -> str:
3135
# Windows is special. It has unique time zone names (in several
3236
# meanings of the word) available, but unfortunately, they can be
3337
# translated to the language of the operating system, so we need to
@@ -86,7 +90,7 @@ def get_localzone_name():
8690
return timezone
8791

8892

89-
def _get_localzone():
93+
def _get_localzone() -> pytz.BaseTzInfo:
9094
if winreg is None:
9195
raise pytz.UnknownTimeZoneError(
9296
'Runtime support not available')

0 commit comments

Comments
 (0)