Skip to content

Commit 2b7b975

Browse files
authored
TYP: types for tz_compare (#35093)
1 parent 8d10bfb commit 2b7b975

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

pandas/_libs/lib.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ from pandas._libs.tslibs.nattype cimport (
7373
)
7474
from pandas._libs.tslibs.conversion cimport convert_to_tsobject
7575
from pandas._libs.tslibs.timedeltas cimport convert_to_timedelta64
76-
from pandas._libs.tslibs.timezones cimport get_timezone, tz_compare
76+
from pandas._libs.tslibs.timezones cimport tz_compare
7777
from pandas._libs.tslibs.period cimport is_period_object
7878
from pandas._libs.tslibs.offsets cimport is_offset_object
7979

@@ -1789,7 +1789,7 @@ def is_datetime_with_singletz_array(values: ndarray) -> bool:
17891789
for i in range(n):
17901790
base_val = values[i]
17911791
if base_val is not NaT:
1792-
base_tz = get_timezone(getattr(base_val, 'tzinfo', None))
1792+
base_tz = getattr(base_val, 'tzinfo', None)
17931793
break
17941794

17951795
for j in range(i, n):

pandas/_libs/tslibs/timezones.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cdef bint is_tzlocal(tzinfo tz)
77

88
cdef bint treat_tz_as_pytz(tzinfo tz)
99

10-
cpdef bint tz_compare(object start, object end)
10+
cpdef bint tz_compare(tzinfo start, tzinfo end)
1111
cpdef object get_timezone(object tz)
1212
cpdef object maybe_get_tz(object tz)
1313

pandas/_libs/tslibs/timezones.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def infer_tzinfo(datetime start, datetime end):
301301
return tz
302302

303303

304-
cpdef bint tz_compare(object start, object end):
304+
cpdef bint tz_compare(tzinfo start, tzinfo end):
305305
"""
306306
Compare string representations of timezones
307307
@@ -324,7 +324,6 @@ cpdef bint tz_compare(object start, object end):
324324
Returns:
325325
-------
326326
bool
327-
328327
"""
329328
# GH 18523
330329
return get_timezone(start) == get_timezone(end)

pandas/core/arrays/datetimes.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,9 @@ def validate_tz_from_dtype(dtype, tz: Optional[tzinfo]) -> Optional[tzinfo]:
22662266
return tz
22672267

22682268

2269-
def _infer_tz_from_endpoints(start, end, tz):
2269+
def _infer_tz_from_endpoints(
2270+
start: Timestamp, end: Timestamp, tz: Optional[tzinfo]
2271+
) -> Optional[tzinfo]:
22702272
"""
22712273
If a timezone is not explicitly given via `tz`, see if one can
22722274
be inferred from the `start` and `end` endpoints. If more than one

0 commit comments

Comments
 (0)