Skip to content

Commit 8acec7a

Browse files
authored
Zip Strict for pandas/util and pandas/_libs #62469 (#62540)
1 parent 833f192 commit 8acec7a

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

pandas/_libs/index.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ cdef class BaseMultiIndexCodesEngine:
838838
raise KeyError(key)
839839
try:
840840
indices = [1 if checknull(v) else lev.get_loc(v) + multiindex_nulls_shift
841-
for lev, v in zip(self.levels, key)]
841+
for lev, v in zip(self.levels, key, strict=True)]
842842
except KeyError:
843843
raise KeyError(key)
844844

pandas/_libs/missing.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ cpdef bint check_na_tuples_nonequal(object left, object right):
7272
if len(left) != len(right):
7373
return False
7474

75-
for left_element, right_element in zip(left, right):
75+
for left_element, right_element in zip(left, right, strict=True):
7676
if left_element is C_NA and right_element is not C_NA:
7777
return True
7878
elif right_element is C_NA and left_element is not C_NA:

pandas/_libs/tslibs/fields.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def month_position_check(fields, weekdays) -> str | None:
109109
int32_t[:] months = fields["M"]
110110
int32_t[:] days = fields["D"]
111111

112-
for y, m, d, wd in zip(years, months, days, weekdays):
112+
for y, m, d, wd in zip(years, months, days, weekdays, strict=True):
113113
if calendar_start:
114114
calendar_start &= d == 1
115115
if business_start:

pandas/_libs/tslibs/offsets.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ cdef class BusinessHour(BusinessMixin):
22172217
# Use python string formatting to be faster than strftime
22182218
hours = ",".join(
22192219
f"{st.hour:02d}:{st.minute:02d}-{en.hour:02d}:{en.minute:02d}"
2220-
for st, en in zip(self.start, self.end)
2220+
for st, en in zip(self.start, self.end, strict=True)
22212221
)
22222222
attrs = [f"{self._prefix}={hours}"]
22232223
out += ": " + ", ".join(attrs)
@@ -2414,7 +2414,7 @@ cdef class BusinessHour(BusinessMixin):
24142414
# get total business hours by sec in one business day
24152415
businesshours = sum(
24162416
self._get_business_hours_by_sec(st, en)
2417-
for st, en in zip(self.start, self.end)
2417+
for st, en in zip(self.start, self.end, strict=True)
24182418
)
24192419

24202420
bd, r = divmod(abs(n * 60), businesshours // 60)
@@ -5357,7 +5357,7 @@ cpdef to_offset(freq, bint is_period=False):
53575357
# the last element must be blank
53585358
raise ValueError("last element must be blank")
53595359

5360-
tups = zip(split[0::4], split[1::4], split[2::4])
5360+
tups = zip(split[0::4], split[1::4], split[2::4], strict=False)
53615361
for n, (sep, stride, name) in enumerate(tups):
53625362
name = _warn_about_deprecated_aliases(name, is_period)
53635363
_validate_to_offset_alias(name, is_period)

pandas/_libs/tslibs/timezones.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ cdef object _get_utc_trans_times_from_dateutil_tz(tzinfo tz):
252252
"""
253253
new_trans = list(tz._trans_list)
254254
last_std_offset = 0
255-
for i, (trans, tti) in enumerate(zip(tz._trans_list, tz._trans_idx)):
255+
for i, (trans, tti) in enumerate(zip(tz._trans_list, tz._trans_idx, strict=True)):
256256
if not tti.isdst:
257257
last_std_offset = tti.offset
258258
new_trans[i] = trans - last_std_offset

pandas/util/_doctools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def plot(
8484
# left
8585
max_left_cols = max(self._shape(df)[1] for df in left)
8686
max_left_rows = max(self._shape(df)[0] for df in left)
87-
for i, (_left, _label) in enumerate(zip(left, labels)):
87+
for i, (_left, _label) in enumerate(zip(left, labels, strict=True)):
8888
ax = fig.add_subplot(gs[i, 0:max_left_cols])
8989
self._make_table(ax, _left, title=_label, height=1.0 / max_left_rows)
9090
# right
@@ -97,7 +97,7 @@ def plot(
9797
gs = gridspec.GridSpec(1, hcells)
9898
# left
9999
i = 0
100-
for df, _label in zip(left, labels):
100+
for df, _label in zip(left, labels, strict=True):
101101
sp = self._shape(df)
102102
ax = fig.add_subplot(gs[0, i : i + sp[1]])
103103
self._make_table(ax, df, title=_label, height=height)

pandas/util/_validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def validate_args(fname, args, max_fname_arg_count, compat_args) -> None:
122122
# We do this so that we can provide a more informative
123123
# error message about the parameters that we are not
124124
# supporting in the pandas implementation of 'fname'
125-
kwargs = dict(zip(compat_args, args))
125+
kwargs = dict(zip(compat_args, args, strict=False))
126126
_check_for_default_values(fname, kwargs, compat_args)
127127

128128

@@ -212,7 +212,7 @@ def validate_args_and_kwargs(
212212

213213
# Check there is no overlap with the positional and keyword
214214
# arguments, similar to what is done in actual Python functions
215-
args_dict = dict(zip(compat_args, args))
215+
args_dict = dict(zip(compat_args, args, strict=False))
216216

217217
for key in args_dict:
218218
if key in kwargs:

0 commit comments

Comments
 (0)