File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import 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
Original file line number Diff line number Diff line change 33except 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+
710import 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.
1418try :
15- tz_names = get_global ('windows_zone_mapping' )
19+ tz_names : dict [ str , str ] = cast ( Dict [ str , str ], get_global ('windows_zone_mapping' ) )
1620except 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' )
You can’t perform that action at this time.
0 commit comments