From 6ff123e6b0fa20f578ce0b16b1751a622db25a26 Mon Sep 17 00:00:00 2001 From: Gowtham Kumar K Date: Sun, 5 Oct 2025 15:11:01 +0530 Subject: [PATCH] STY: Add strict parameter with appropriate value in zip() in pandas/tests/series/methods/ --- pandas/tests/series/methods/test_convert_dtypes.py | 7 +++++-- pandas/tests/series/methods/test_rename.py | 2 +- pandas/tests/series/methods/test_replace.py | 2 +- pandas/tests/series/methods/test_reset_index.py | 2 +- pandas/tests/series/methods/test_sort_index.py | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pandas/tests/series/methods/test_convert_dtypes.py b/pandas/tests/series/methods/test_convert_dtypes.py index ef034e62bb764..57d0c60118504 100644 --- a/pandas/tests/series/methods/test_convert_dtypes.py +++ b/pandas/tests/series/methods/test_convert_dtypes.py @@ -209,11 +209,14 @@ def test_convert_dtypes( "convert_boolean", "convert_floating", ] - params_dict = dict(zip(param_names, params)) + params_dict = dict(zip(param_names, params, strict=True)) expected_dtype = expected_default for spec, dtype in expected_other.items(): - if all(params_dict[key] is val for key, val in zip(spec[::2], spec[1::2])): + if all( + params_dict[key] is val + for key, val in zip(spec[::2], spec[1::2], strict=False) + ): expected_dtype = dtype if ( using_infer_string diff --git a/pandas/tests/series/methods/test_rename.py b/pandas/tests/series/methods/test_rename.py index f5a97d61990a4..c912b9abd22ca 100644 --- a/pandas/tests/series/methods/test_rename.py +++ b/pandas/tests/series/methods/test_rename.py @@ -21,7 +21,7 @@ def test_rename(self, datetime_series): assert renamed.index[0] == renamer(ts.index[0]) # dict - rename_dict = dict(zip(ts.index, renamed.index)) + rename_dict = dict(zip(ts.index, renamed.index, strict=True)) renamed2 = ts.rename(rename_dict) tm.assert_series_equal(renamed, renamed2) diff --git a/pandas/tests/series/methods/test_replace.py b/pandas/tests/series/methods/test_replace.py index 7d068c2120735..f7383dd967cbe 100644 --- a/pandas/tests/series/methods/test_replace.py +++ b/pandas/tests/series/methods/test_replace.py @@ -648,7 +648,7 @@ def test_replace_different_int_types(self, any_int_numpy_dtype): labs = pd.Series([1, 1, 1, 0, 0, 2, 2, 2], dtype=any_int_numpy_dtype) maps = pd.Series([0, 2, 1], dtype=any_int_numpy_dtype) - map_dict = dict(zip(maps.values, maps.index)) + map_dict = dict(zip(maps.values, maps.index, strict=True)) result = labs.replace(map_dict) expected = labs.replace({0: 0, 2: 1, 1: 2}) diff --git a/pandas/tests/series/methods/test_reset_index.py b/pandas/tests/series/methods/test_reset_index.py index d42aafc001680..3ff39b41a352d 100644 --- a/pandas/tests/series/methods/test_reset_index.py +++ b/pandas/tests/series/methods/test_reset_index.py @@ -146,7 +146,7 @@ def test_reset_index_with_drop(self): ["bar", "bar", "baz", "baz", "qux", "qux", "foo", "foo"], ["one", "two", "one", "two", "one", "two", "one", "two"], ] - tuples = zip(*arrays) + tuples = zip(*arrays, strict=True) index = MultiIndex.from_tuples(tuples) data = np.random.default_rng(2).standard_normal(8) ser = Series(data, index=index) diff --git a/pandas/tests/series/methods/test_sort_index.py b/pandas/tests/series/methods/test_sort_index.py index d6817aa179b7b..861017f448195 100644 --- a/pandas/tests/series/methods/test_sort_index.py +++ b/pandas/tests/series/methods/test_sort_index.py @@ -186,7 +186,7 @@ def test_sort_index_ascending_list(self): ["one", "two", "one", "two", "one", "two", "one", "two"], [4, 3, 2, 1, 4, 3, 2, 1], ] - tuples = zip(*arrays) + tuples = zip(*arrays, strict=True) mi = MultiIndex.from_tuples(tuples, names=["first", "second", "third"]) ser = Series(range(8), index=mi)