diff --git a/pandas/tests/extension/base/methods.py b/pandas/tests/extension/base/methods.py index 084ee61243fd0..a2bf621a04669 100644 --- a/pandas/tests/extension/base/methods.py +++ b/pandas/tests/extension/base/methods.py @@ -350,7 +350,10 @@ def test_combine_le(self, data_repeated): result = s1.combine(s2, lambda x1, x2: x1 <= x2) expected = pd.Series( pd.array( - [a <= b for (a, b) in zip(list(orig_data1), list(orig_data2))], + [ + a <= b + for (a, b) in zip(list(orig_data1), list(orig_data2), strict=True) + ], dtype=self._combine_le_expected_dtype, ) ) @@ -369,7 +372,7 @@ def test_combine_le(self, data_repeated): def _construct_for_combine_add(self, left, right): if isinstance(right, type(left)): return left._from_sequence( - [a + b for (a, b) in zip(list(left), list(right))], + [a + b for (a, b) in zip(list(left), list(right), strict=True)], dtype=left.dtype, ) else: @@ -627,7 +630,7 @@ def test_repeat(self, data, repeats, as_series, use_numpy): result = np.repeat(arr, repeats) if use_numpy else arr.repeat(repeats) repeats = [repeats] * 3 if isinstance(repeats, int) else repeats - expected = [x for x, n in zip(arr, repeats) for _ in range(n)] + expected = [x for x, n in zip(arr, repeats, strict=True) for _ in range(n)] expected = type(data)._from_sequence(expected, dtype=data.dtype) if as_series: expected = pd.Series(expected, index=arr.index.repeat(repeats)) diff --git a/pandas/tests/extension/date/array.py b/pandas/tests/extension/date/array.py index dd275b01e734e..b97c20ad24f32 100644 --- a/pandas/tests/extension/date/array.py +++ b/pandas/tests/extension/date/array.py @@ -162,7 +162,7 @@ def __setitem__(self, key: int | slice | np.ndarray, value: Any) -> None: self._day[key] = value.day def __repr__(self) -> str: - return f"DateArray{list(zip(self._year, self._month, self._day))}" + return f"DateArray{list(zip(self._year, self._month, self._day, strict=True))}" def copy(self) -> DateArray: return DateArray((self._year.copy(), self._month.copy(), self._day.copy())) diff --git a/pandas/tests/extension/decimal/array.py b/pandas/tests/extension/decimal/array.py index ab6e520fcf0b3..7d055e2143112 100644 --- a/pandas/tests/extension/decimal/array.py +++ b/pandas/tests/extension/decimal/array.py @@ -295,7 +295,7 @@ def convert_values(param): # If the operator is not defined for the underlying objects, # a TypeError should be raised - res = [op(a, b) for (a, b) in zip(lvalues, rvalues)] + res = [op(a, b) for (a, b) in zip(lvalues, rvalues, strict=True)] return np.asarray(res, dtype=bool) diff --git a/pandas/tests/extension/json/array.py b/pandas/tests/extension/json/array.py index 164e0e517d6aa..1878fac1b8111 100644 --- a/pandas/tests/extension/json/array.py +++ b/pandas/tests/extension/json/array.py @@ -128,7 +128,7 @@ def __getitem__(self, item): item = pd.api.indexers.check_array_indexer(self, item) if is_bool_dtype(item.dtype): return type(self)._from_sequence( - [x for x, m in zip(self, item) if m], dtype=self.dtype + [x for x, m in zip(self, item, strict=True) if m], dtype=self.dtype ) # integer return type(self)([self.data[i] for i in item]) @@ -146,12 +146,12 @@ def __setitem__(self, key, value) -> None: if isinstance(key, np.ndarray) and key.dtype == "bool": # masking - for i, (k, v) in enumerate(zip(key, value)): + for i, (k, v) in enumerate(zip(key, value, strict=False)): if k: assert isinstance(v, self.dtype.type) self.data[i] = v else: - for k, v in zip(key, value): + for k, v in zip(key, value, strict=False): assert isinstance(v, self.dtype.type) self.data[k] = v diff --git a/pandas/tests/extension/test_arrow.py b/pandas/tests/extension/test_arrow.py index c34d7667c2cca..ba5d257bd59e4 100644 --- a/pandas/tests/extension/test_arrow.py +++ b/pandas/tests/extension/test_arrow.py @@ -282,7 +282,7 @@ def _construct_for_combine_add(self, left, right): if isinstance(right, type(left)): return left._from_sequence( - [a + b for (a, b) in zip(list(left), list(right))], + [a + b for (a, b) in zip(list(left), list(right), strict=True)], dtype=dtype, ) else: diff --git a/pandas/tests/extension/test_categorical.py b/pandas/tests/extension/test_categorical.py index 275f8e2f859a4..eb671e74f4b25 100644 --- a/pandas/tests/extension/test_categorical.py +++ b/pandas/tests/extension/test_categorical.py @@ -126,7 +126,7 @@ def test_combine_add(self, data_repeated): s2 = pd.Series(orig_data2) result = s1.combine(s2, lambda x1, x2: x1 + x2) expected = pd.Series( - [a + b for (a, b) in zip(list(orig_data1), list(orig_data2))] + [a + b for (a, b) in zip(list(orig_data1), list(orig_data2), strict=True)] ) tm.assert_series_equal(result, expected) diff --git a/pandas/tests/extension/test_interval.py b/pandas/tests/extension/test_interval.py index ada34e7ace680..47bc26ba4a766 100644 --- a/pandas/tests/extension/test_interval.py +++ b/pandas/tests/extension/test_interval.py @@ -34,7 +34,10 @@ def make_data(n: int): left_array = np.random.default_rng(2).uniform(size=n).cumsum() right_array = left_array + np.random.default_rng(2).uniform(size=n) - return [Interval(left, right) for left, right in zip(left_array, right_array)] + return [ + Interval(left, right) + for left, right in zip(left_array, right_array, strict=True) + ] @pytest.fixture