Skip to content

TYP: types for tz_compare #35093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ from pandas._libs.tslibs.nattype cimport (
)
from pandas._libs.tslibs.conversion cimport convert_to_tsobject
from pandas._libs.tslibs.timedeltas cimport convert_to_timedelta64
from pandas._libs.tslibs.timezones cimport get_timezone, tz_compare
from pandas._libs.tslibs.timezones cimport tz_compare
from pandas._libs.tslibs.period cimport is_period_object
from pandas._libs.tslibs.offsets cimport is_offset_object

Expand Down Expand Up @@ -1789,7 +1789,7 @@ def is_datetime_with_singletz_array(values: ndarray) -> bool:
for i in range(n):
base_val = values[i]
if base_val is not NaT:
base_tz = get_timezone(getattr(base_val, 'tzinfo', None))
base_tz = getattr(base_val, 'tzinfo', None)
break

for j in range(i, n):
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/timezones.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cdef bint is_tzlocal(tzinfo tz)

cdef bint treat_tz_as_pytz(tzinfo tz)

cpdef bint tz_compare(object start, object end)
cpdef bint tz_compare(tzinfo start, tzinfo end)
cpdef object get_timezone(object tz)
cpdef object maybe_get_tz(object tz)

Expand Down
3 changes: 1 addition & 2 deletions pandas/_libs/tslibs/timezones.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def infer_tzinfo(datetime start, datetime end):
return tz


cpdef bint tz_compare(object start, object end):
cpdef bint tz_compare(tzinfo start, tzinfo end):
"""
Compare string representations of timezones

Expand All @@ -324,7 +324,6 @@ cpdef bint tz_compare(object start, object end):
Returns:
-------
bool

"""
# GH 18523
return get_timezone(start) == get_timezone(end)
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,9 @@ def validate_tz_from_dtype(dtype, tz: Optional[tzinfo]) -> Optional[tzinfo]:
return tz


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