Skip to content

Commit 18b3af6

Browse files
authored
CLN: typing in libtimezones (#35079)
1 parent f451a23 commit 18b3af6

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

pandas/_libs/tslibs/timezones.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ cpdef object maybe_get_tz(object tz)
1414
cdef get_utcoffset(tzinfo tz, obj)
1515
cdef bint is_fixed_offset(tzinfo tz)
1616

17-
cdef object get_dst_info(object tz)
17+
cdef object get_dst_info(tzinfo tz)

pandas/_libs/tslibs/timezones.pyx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _p_tz_cache_key(tz):
116116
dst_cache = {}
117117

118118

119-
cdef inline object tz_cache_key(object tz):
119+
cdef inline object tz_cache_key(tzinfo tz):
120120
"""
121121
Return the key in the cache for the timezone info object or None
122122
if unknown.
@@ -210,13 +210,16 @@ cdef int64_t[:] unbox_utcoffsets(object transinfo):
210210
# Daylight Savings
211211

212212

213-
cdef object get_dst_info(object tz):
213+
cdef object get_dst_info(tzinfo tz):
214214
"""
215-
return a tuple of :
216-
(UTC times of DST transitions,
217-
UTC offsets in microseconds corresponding to DST transitions,
218-
string of type of transitions)
219-
215+
Returns
216+
-------
217+
ndarray[int64_t]
218+
Nanosecond UTC times of DST transitions.
219+
ndarray[int64_t]
220+
Nanosecond UTC offsets corresponding to DST transitions.
221+
str
222+
Desscribing the type of tzinfo object.
220223
"""
221224
cache_key = tz_cache_key(tz)
222225
if cache_key is None:
@@ -225,7 +228,7 @@ cdef object get_dst_info(object tz):
225228
num = int(get_utcoffset(tz, None).total_seconds()) * 1_000_000_000
226229
return (np.array([NPY_NAT + 1], dtype=np.int64),
227230
np.array([num], dtype=np.int64),
228-
None)
231+
"unknown")
229232

230233
if cache_key not in dst_cache:
231234
if treat_tz_as_pytz(tz):
@@ -267,14 +270,13 @@ cdef object get_dst_info(object tz):
267270
# (under the just-deleted code that returned empty arrays)
268271
raise AssertionError("dateutil tzinfo is not a FixedOffset "
269272
"and has an empty `_trans_list`.", tz)
270-
271273
else:
272-
# static tzinfo
273-
# TODO: This case is not hit in tests (2018-07-17); is it possible?
274+
# static tzinfo, we can get here with pytz.StaticTZInfo
275+
# which are not caught by treat_tz_as_pytz
274276
trans = np.array([NPY_NAT + 1], dtype=np.int64)
275-
num = int(get_utcoffset(tz, None).total_seconds()) * 1000000000
277+
num = int(get_utcoffset(tz, None).total_seconds()) * 1_000_000_000
276278
deltas = np.array([num], dtype=np.int64)
277-
typ = 'static'
279+
typ = "static"
278280

279281
dst_cache[cache_key] = (trans, deltas, typ)
280282

0 commit comments

Comments
 (0)