From 0364b92262d4808597d64968f128bd9f1f14b94a Mon Sep 17 00:00:00 2001 From: vishal Date: Wed, 1 Oct 2025 23:54:40 +0100 Subject: [PATCH] Zip Strict for pandas/util and pandas/_libs --- pandas/_libs/index.pyx | 2 +- pandas/_libs/missing.pyx | 2 +- pandas/_libs/tslibs/fields.pyx | 2 +- pandas/_libs/tslibs/offsets.pyx | 6 +++--- pandas/_libs/tslibs/timezones.pyx | 2 +- pandas/util/_doctools.py | 4 ++-- pandas/util/_validators.py | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index 73667afcbb4e0..e6f59f8518754 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -838,7 +838,7 @@ cdef class BaseMultiIndexCodesEngine: raise KeyError(key) try: indices = [1 if checknull(v) else lev.get_loc(v) + multiindex_nulls_shift - for lev, v in zip(self.levels, key)] + for lev, v in zip(self.levels, key, strict=True)] except KeyError: raise KeyError(key) diff --git a/pandas/_libs/missing.pyx b/pandas/_libs/missing.pyx index 5fbd5be475905..a7aea7e766304 100644 --- a/pandas/_libs/missing.pyx +++ b/pandas/_libs/missing.pyx @@ -72,7 +72,7 @@ cpdef bint check_na_tuples_nonequal(object left, object right): if len(left) != len(right): return False - for left_element, right_element in zip(left, right): + for left_element, right_element in zip(left, right, strict=True): if left_element is C_NA and right_element is not C_NA: return True elif right_element is C_NA and left_element is not C_NA: diff --git a/pandas/_libs/tslibs/fields.pyx b/pandas/_libs/tslibs/fields.pyx index e523ac2e7b5c6..c1db313fa5157 100644 --- a/pandas/_libs/tslibs/fields.pyx +++ b/pandas/_libs/tslibs/fields.pyx @@ -109,7 +109,7 @@ def month_position_check(fields, weekdays) -> str | None: int32_t[:] months = fields["M"] int32_t[:] days = fields["D"] - for y, m, d, wd in zip(years, months, days, weekdays): + for y, m, d, wd in zip(years, months, days, weekdays, strict=True): if calendar_start: calendar_start &= d == 1 if business_start: diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index a0d85fc44eb96..dfc1fd0fe5630 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -2217,7 +2217,7 @@ cdef class BusinessHour(BusinessMixin): # Use python string formatting to be faster than strftime hours = ",".join( f"{st.hour:02d}:{st.minute:02d}-{en.hour:02d}:{en.minute:02d}" - for st, en in zip(self.start, self.end) + for st, en in zip(self.start, self.end, strict=True) ) attrs = [f"{self._prefix}={hours}"] out += ": " + ", ".join(attrs) @@ -2414,7 +2414,7 @@ cdef class BusinessHour(BusinessMixin): # get total business hours by sec in one business day businesshours = sum( self._get_business_hours_by_sec(st, en) - for st, en in zip(self.start, self.end) + for st, en in zip(self.start, self.end, strict=True) ) bd, r = divmod(abs(n * 60), businesshours // 60) @@ -5357,7 +5357,7 @@ cpdef to_offset(freq, bint is_period=False): # the last element must be blank raise ValueError("last element must be blank") - tups = zip(split[0::4], split[1::4], split[2::4]) + tups = zip(split[0::4], split[1::4], split[2::4], strict=False) for n, (sep, stride, name) in enumerate(tups): name = _warn_about_deprecated_aliases(name, is_period) _validate_to_offset_alias(name, is_period) diff --git a/pandas/_libs/tslibs/timezones.pyx b/pandas/_libs/tslibs/timezones.pyx index 36b644ffc826d..b02ddbcaf18e9 100644 --- a/pandas/_libs/tslibs/timezones.pyx +++ b/pandas/_libs/tslibs/timezones.pyx @@ -252,7 +252,7 @@ cdef object _get_utc_trans_times_from_dateutil_tz(tzinfo tz): """ new_trans = list(tz._trans_list) last_std_offset = 0 - for i, (trans, tti) in enumerate(zip(tz._trans_list, tz._trans_idx)): + for i, (trans, tti) in enumerate(zip(tz._trans_list, tz._trans_idx, strict=True)): if not tti.isdst: last_std_offset = tti.offset new_trans[i] = trans - last_std_offset diff --git a/pandas/util/_doctools.py b/pandas/util/_doctools.py index 828b7a4591bf2..a980b4040909e 100644 --- a/pandas/util/_doctools.py +++ b/pandas/util/_doctools.py @@ -84,7 +84,7 @@ def plot( # left max_left_cols = max(self._shape(df)[1] for df in left) max_left_rows = max(self._shape(df)[0] for df in left) - for i, (_left, _label) in enumerate(zip(left, labels)): + for i, (_left, _label) in enumerate(zip(left, labels, strict=True)): ax = fig.add_subplot(gs[i, 0:max_left_cols]) self._make_table(ax, _left, title=_label, height=1.0 / max_left_rows) # right @@ -97,7 +97,7 @@ def plot( gs = gridspec.GridSpec(1, hcells) # left i = 0 - for df, _label in zip(left, labels): + for df, _label in zip(left, labels, strict=True): sp = self._shape(df) ax = fig.add_subplot(gs[0, i : i + sp[1]]) self._make_table(ax, df, title=_label, height=height) diff --git a/pandas/util/_validators.py b/pandas/util/_validators.py index 9aab19fe340ec..f7e878b0633d3 100644 --- a/pandas/util/_validators.py +++ b/pandas/util/_validators.py @@ -122,7 +122,7 @@ def validate_args(fname, args, max_fname_arg_count, compat_args) -> None: # We do this so that we can provide a more informative # error message about the parameters that we are not # supporting in the pandas implementation of 'fname' - kwargs = dict(zip(compat_args, args)) + kwargs = dict(zip(compat_args, args, strict=False)) _check_for_default_values(fname, kwargs, compat_args) @@ -212,7 +212,7 @@ def validate_args_and_kwargs( # Check there is no overlap with the positional and keyword # arguments, similar to what is done in actual Python functions - args_dict = dict(zip(compat_args, args)) + args_dict = dict(zip(compat_args, args, strict=False)) for key in args_dict: if key in kwargs: