From b6dbad726a3e32c594846f2d31f1db8aff6c8d52 Mon Sep 17 00:00:00 2001 From: Minh Date: Mon, 6 Oct 2025 19:50:02 -0400 Subject: [PATCH 1/2] STY: add strict=... to zip() in pandas/tests/indexes (B905) --- pandas/tests/indexes/categorical/test_map.py | 2 +- .../indexes/datetimes/methods/test_astype.py | 6 +++--- pandas/tests/indexes/datetimes/test_formats.py | 6 +++--- .../indexes/datetimes/test_partial_slicing.py | 4 ++-- .../indexes/datetimes/test_scalar_compat.py | 4 ++-- pandas/tests/indexes/datetimes/test_timezones.py | 2 +- .../tests/indexes/interval/test_constructors.py | 4 ++-- pandas/tests/indexes/interval/test_formats.py | 2 +- pandas/tests/indexes/interval/test_interval.py | 16 ++++++++-------- pandas/tests/indexes/multi/test_analytics.py | 2 +- pandas/tests/indexes/multi/test_constructors.py | 8 ++++---- pandas/tests/indexes/multi/test_equivalence.py | 2 +- pandas/tests/indexes/multi/test_get_set.py | 2 +- .../tests/indexes/period/methods/test_asfreq.py | 2 +- pandas/tests/indexes/period/test_constructors.py | 2 +- pandas/tests/indexes/period/test_formats.py | 6 +++--- pandas/tests/indexes/period/test_period.py | 4 ++-- pandas/tests/indexes/test_base.py | 6 +++--- pandas/tests/indexes/test_datetimelike.py | 2 +- pandas/tests/indexes/test_old_base.py | 2 +- pandas/tests/indexes/test_setops.py | 2 +- pandas/tests/indexes/timedeltas/test_formats.py | 6 +++--- 22 files changed, 46 insertions(+), 46 deletions(-) diff --git a/pandas/tests/indexes/categorical/test_map.py b/pandas/tests/indexes/categorical/test_map.py index baf836594dfb5..36605a2c9990d 100644 --- a/pandas/tests/indexes/categorical/test_map.py +++ b/pandas/tests/indexes/categorical/test_map.py @@ -138,7 +138,7 @@ def test_map_with_dict_or_series(): # Order of categories in result can be different tm.assert_index_equal(result, expected) - mapper = dict(zip(orig_values[:-1], new_values[:-1])) + mapper = dict(zip(orig_values[:-1], new_values[:-1], strict=True)) result = cur_index.map(mapper) # Order of categories in result can be different tm.assert_index_equal(result, expected) diff --git a/pandas/tests/indexes/datetimes/methods/test_astype.py b/pandas/tests/indexes/datetimes/methods/test_astype.py index 62be8903da206..6fcc166ac9ab9 100644 --- a/pandas/tests/indexes/datetimes/methods/test_astype.py +++ b/pandas/tests/indexes/datetimes/methods/test_astype.py @@ -239,7 +239,7 @@ def test_index_convert_to_datetime_array(self): def _check_rng(rng): converted = rng.to_pydatetime() assert isinstance(converted, np.ndarray) - for x, stamp in zip(converted, rng): + for x, stamp in zip(converted, rng, strict=True): assert isinstance(x, datetime) assert x == stamp.to_pydatetime() assert x.tzinfo == stamp.tzinfo @@ -258,7 +258,7 @@ def test_index_convert_to_datetime_array_explicit_pytz(self): def _check_rng(rng): converted = rng.to_pydatetime() assert isinstance(converted, np.ndarray) - for x, stamp in zip(converted, rng): + for x, stamp in zip(converted, rng, strict=True): assert isinstance(x, datetime) assert x == stamp.to_pydatetime() assert x.tzinfo == stamp.tzinfo @@ -275,7 +275,7 @@ def test_index_convert_to_datetime_array_dateutil(self): def _check_rng(rng): converted = rng.to_pydatetime() assert isinstance(converted, np.ndarray) - for x, stamp in zip(converted, rng): + for x, stamp in zip(converted, rng, strict=True): assert isinstance(x, datetime) assert x == stamp.to_pydatetime() assert x.tzinfo == stamp.tzinfo diff --git a/pandas/tests/indexes/datetimes/test_formats.py b/pandas/tests/indexes/datetimes/test_formats.py index f4e0a63043335..88301878b5ed5 100644 --- a/pandas/tests/indexes/datetimes/test_formats.py +++ b/pandas/tests/indexes/datetimes/test_formats.py @@ -175,7 +175,7 @@ def test_dti_representation(self, unit): ) with pd.option_context("display.width", 300): - for index, expected in zip(idxs, exp): + for index, expected in zip(idxs, exp, strict=True): index = index.as_unit(unit) expected = expected.replace("[ns", f"[{unit}") result = repr(index) @@ -226,7 +226,7 @@ def test_dti_representation_to_series(self, unit): with pd.option_context("display.width", 300): for idx, expected in zip( [idx1, idx2, idx3, idx4, idx5, idx6, idx7], - [exp1, exp2, exp3, exp4, exp5, exp6, exp7], + [exp1, exp2, exp3, exp4, exp5, exp6, exp7], strict=True, ): ser = Series(idx.as_unit(unit)) result = repr(ser) @@ -264,7 +264,7 @@ def test_dti_summary(self): exp6 = """DatetimeIndex: 3 entries, 2011-01-01 09:00:00-05:00 to NaT""" for idx, expected in zip( - [idx1, idx2, idx3, idx4, idx5, idx6], [exp1, exp2, exp3, exp4, exp5, exp6] + [idx1, idx2, idx3, idx4, idx5, idx6], [exp1, exp2, exp3, exp4, exp5, exp6], strict=True ): result = idx._summary() assert result == expected diff --git a/pandas/tests/indexes/datetimes/test_partial_slicing.py b/pandas/tests/indexes/datetimes/test_partial_slicing.py index 94175a56f1c4a..18e5b9411b44e 100644 --- a/pandas/tests/indexes/datetimes/test_partial_slicing.py +++ b/pandas/tests/indexes/datetimes/test_partial_slicing.py @@ -279,7 +279,7 @@ def test_partial_slicing_dataframe(self): # Timestamp with the same resolution as index # Should be exact match for Series (return scalar) # and raise KeyError for Frame - for timestamp, expected in zip(index, values): + for timestamp, expected in zip(index, values, strict=True): ts_string = timestamp.strftime(formats[rnum]) # make ts_string as precise as index result = df["a"][ts_string] @@ -319,7 +319,7 @@ def test_partial_slicing_dataframe(self): # Not compatible with existing key # Should raise KeyError - for fmt, res in list(zip(formats, resolutions))[rnum + 1 :]: + for fmt, res in list(zip(formats, resolutions, strict=True))[rnum + 1 :]: ts = index[1] + Timedelta("1 " + res) ts_string = ts.strftime(fmt) msg = rf"^'{ts_string}'$" diff --git a/pandas/tests/indexes/datetimes/test_scalar_compat.py b/pandas/tests/indexes/datetimes/test_scalar_compat.py index eb472b099fb1f..c43799dcaa9c5 100644 --- a/pandas/tests/indexes/datetimes/test_scalar_compat.py +++ b/pandas/tests/indexes/datetimes/test_scalar_compat.py @@ -184,7 +184,7 @@ def test_day_name_month_name(self, time_locale): "Saturday", "Sunday", ] - for day, name, eng_name in zip(range(4, 11), expected_days, english_days): + for day, name, eng_name in zip(range(4, 11), expected_days, english_days, strict=True): name = name.capitalize() assert dti.day_name(locale=time_locale)[day] == name assert dti.day_name(locale=None)[day] == eng_name @@ -206,7 +206,7 @@ def test_day_name_month_name(self, time_locale): tm.assert_index_equal(result, expected) - for item, expected in zip(dti, expected_months): + for item, expected in zip(dti, expected_months, strict=True): result = item.month_name(locale=time_locale) expected = expected.capitalize() diff --git a/pandas/tests/indexes/datetimes/test_timezones.py b/pandas/tests/indexes/datetimes/test_timezones.py index 8d9340818b511..0fff6be1d9d51 100644 --- a/pandas/tests/indexes/datetimes/test_timezones.py +++ b/pandas/tests/indexes/datetimes/test_timezones.py @@ -162,7 +162,7 @@ def test_timestamp_equality_different_timezones(self): eastern_range = utc_range.tz_convert("US/Eastern") berlin_range = utc_range.tz_convert("Europe/Berlin") - for a, b, c in zip(utc_range, eastern_range, berlin_range): + for a, b, c in zip(utc_range, eastern_range, berlin_range, strict=True): assert a == b assert b == c assert a == c diff --git a/pandas/tests/indexes/interval/test_constructors.py b/pandas/tests/indexes/interval/test_constructors.py index 90423149658ab..2ffdaf9734aa1 100644 --- a/pandas/tests/indexes/interval/test_constructors.py +++ b/pandas/tests/indexes/interval/test_constructors.py @@ -333,7 +333,7 @@ def get_kwargs_from_breaks(self, breaks, closed="right"): if len(breaks) == 0: return {"data": breaks} - tuples = list(zip(breaks[:-1], breaks[1:])) + tuples = list(zip(breaks[:-1], breaks[1:], strict=True)) if isinstance(breaks, (list, tuple)): return {"data": tuples} elif isinstance(getattr(breaks, "dtype", None), CategoricalDtype): @@ -386,7 +386,7 @@ def get_kwargs_from_breaks(self, breaks, closed="right"): ivs = [ Interval(left, right, closed) if notna(left) else left - for left, right in zip(breaks[:-1], breaks[1:]) + for left, right in zip(breaks[:-1], breaks[1:], strict=True) ] if isinstance(breaks, list): diff --git a/pandas/tests/indexes/interval/test_formats.py b/pandas/tests/indexes/interval/test_formats.py index d45d894c485c9..ad02378627d7a 100644 --- a/pandas/tests/indexes/interval/test_formats.py +++ b/pandas/tests/indexes/interval/test_formats.py @@ -45,7 +45,7 @@ def test_repr_floats(self): Interval(left, right) for left, right in zip( Index([329.973, 345.137], dtype="float64"), - Index([345.137, 360.191], dtype="float64"), + Index([345.137, 360.191], dtype="float64"), strict=True, ) ] ), diff --git a/pandas/tests/indexes/interval/test_interval.py b/pandas/tests/indexes/interval/test_interval.py index 006a06e529971..cd841ce077b00 100644 --- a/pandas/tests/indexes/interval/test_interval.py +++ b/pandas/tests/indexes/interval/test_interval.py @@ -49,7 +49,7 @@ def test_properties(self, closed): ivs = [ Interval(left, right, closed) - for left, right in zip(range(10), range(1, 11)) + for left, right in zip(range(10), range(1, 11), strict=True) ] expected = np.array(ivs, dtype=object) tm.assert_numpy_array_equal(np.asarray(index), expected) @@ -71,7 +71,7 @@ def test_properties(self, closed): ivs = [ Interval(left, right, closed) if notna(left) else np.nan - for left, right in zip(expected_left, expected_right) + for left, right in zip(expected_left, expected_right, strict=True) ] expected = np.array(ivs, dtype=object) tm.assert_numpy_array_equal(np.asarray(index), expected) @@ -789,14 +789,14 @@ def test_is_overlapping(self, start, shift, na_value, closed): @pytest.mark.parametrize( "tuples", [ - zip(range(10), range(1, 11)), + zip(range(10), range(1, 11), strict=True), zip( date_range("20170101", periods=10), - date_range("20170101", periods=10), + date_range("20170101", periods=10), strict=True, ), zip( timedelta_range("0 days", periods=10), - timedelta_range("1 day", periods=10), + timedelta_range("1 day", periods=10), strict=True, ), ], ) @@ -811,18 +811,18 @@ def test_to_tuples(self, tuples): @pytest.mark.parametrize( "tuples", [ - list(zip(range(10), range(1, 11))) + [np.nan], + list(zip(range(10), range(1, 11), strict=True)) + [np.nan], list( zip( date_range("20170101", periods=10), - date_range("20170101", periods=10), + date_range("20170101", periods=10), strict=True, ) ) + [np.nan], list( zip( timedelta_range("0 days", periods=10), - timedelta_range("1 day", periods=10), + timedelta_range("1 day", periods=10), strict=True, ) ) + [np.nan], diff --git a/pandas/tests/indexes/multi/test_analytics.py b/pandas/tests/indexes/multi/test_analytics.py index 87f1439db5fc8..c161303902308 100644 --- a/pandas/tests/indexes/multi/test_analytics.py +++ b/pandas/tests/indexes/multi/test_analytics.py @@ -185,7 +185,7 @@ def test_map(idx): @pytest.mark.parametrize( "mapper", [ - lambda values, idx: {i: e for e, i in zip(values, idx)}, + lambda values, idx: {i: e for e, i in zip(values, idx, strict=True)}, lambda values, idx: pd.Series(values, idx), ], ) diff --git a/pandas/tests/indexes/multi/test_constructors.py b/pandas/tests/indexes/multi/test_constructors.py index c134e44681122..2bdcfd199da3d 100644 --- a/pandas/tests/indexes/multi/test_constructors.py +++ b/pandas/tests/indexes/multi/test_constructors.py @@ -155,7 +155,7 @@ def test_copy_in_constructor(): def test_from_arrays(idx): arrays = [ np.asarray(lev).take(level_codes) - for lev, level_codes in zip(idx.levels, idx.codes) + for lev, level_codes in zip(idx.levels, idx.codes, strict=True) ] # list of arrays as input @@ -172,7 +172,7 @@ def test_from_arrays_iterator(idx): # GH 18434 arrays = [ np.asarray(lev).take(level_codes) - for lev, level_codes in zip(idx.levels, idx.codes) + for lev, level_codes in zip(idx.levels, idx.codes, strict=True) ] # iterator as input @@ -188,7 +188,7 @@ def test_from_arrays_iterator(idx): def test_from_arrays_tuples(idx): arrays = tuple( tuple(np.asarray(lev).take(level_codes)) - for lev, level_codes in zip(idx.levels, idx.codes) + for lev, level_codes in zip(idx.levels, idx.codes, strict=True) ) # tuple of tuples as input @@ -368,7 +368,7 @@ def test_from_tuples_iterator(): levels=[[1, 3], [2, 4]], codes=[[0, 1], [0, 1]], names=["a", "b"] ) - result = MultiIndex.from_tuples(zip([1, 3], [2, 4]), names=["a", "b"]) + result = MultiIndex.from_tuples(zip([1, 3], [2, 4]), names=["a", "b"], strict=True) tm.assert_index_equal(result, expected) # input non-iterables diff --git a/pandas/tests/indexes/multi/test_equivalence.py b/pandas/tests/indexes/multi/test_equivalence.py index ca155b0e3639d..0d6c638fd8e11 100644 --- a/pandas/tests/indexes/multi/test_equivalence.py +++ b/pandas/tests/indexes/multi/test_equivalence.py @@ -223,7 +223,7 @@ def test_equals_missing_values_differently_sorted(): def test_is_(): - mi = MultiIndex.from_tuples(zip(range(10), range(10))) + mi = MultiIndex.from_tuples(zip(range(10), range(10), strict=True)) assert mi.is_(mi) assert mi.is_(mi.view()) assert mi.is_(mi.view().view().view().view()) diff --git a/pandas/tests/indexes/multi/test_get_set.py b/pandas/tests/indexes/multi/test_get_set.py index 9633681d36b6e..c3cae18bcf83b 100644 --- a/pandas/tests/indexes/multi/test_get_set.py +++ b/pandas/tests/indexes/multi/test_get_set.py @@ -15,7 +15,7 @@ def assert_matching(actual, expected, check_dtype=False): # avoid specifying internal representation # as much as possible assert len(actual) == len(expected) - for act, exp in zip(actual, expected): + for act, exp in zip(actual, expected, strict=True): act = np.asarray(act) exp = np.asarray(exp) tm.assert_numpy_array_equal(act, exp, check_dtype=check_dtype) diff --git a/pandas/tests/indexes/period/methods/test_asfreq.py b/pandas/tests/indexes/period/methods/test_asfreq.py index 8fca53c28a036..47b0718e6125a 100644 --- a/pandas/tests/indexes/period/methods/test_asfreq.py +++ b/pandas/tests/indexes/period/methods/test_asfreq.py @@ -106,7 +106,7 @@ def test_asfreq_mult_pi(self, freq): def test_asfreq_combined_pi(self): pi = PeriodIndex(["2001-01-01 00:00", "2001-01-02 02:00", "NaT"], freq="h") exp = PeriodIndex(["2001-01-01 00:00", "2001-01-02 02:00", "NaT"], freq="25h") - for freq, how in zip(["1D1h", "1h1D"], ["S", "E"]): + for freq, how in zip(["1D1h", "1h1D"], ["S", "E"], strict=True): result = pi.asfreq(freq, how=how) tm.assert_index_equal(result, exp) assert result.freq == exp.freq diff --git a/pandas/tests/indexes/period/test_constructors.py b/pandas/tests/indexes/period/test_constructors.py index ecaaf6183c027..69b4a54d21685 100644 --- a/pandas/tests/indexes/period/test_constructors.py +++ b/pandas/tests/indexes/period/test_constructors.py @@ -430,7 +430,7 @@ def test_constructor_year_and_quarter(self): year = Series([2001, 2002, 2003]) quarter = year - 2000 idx = PeriodIndex.from_fields(year=year, quarter=quarter) - strs = [f"{t[0]:d}Q{t[1]:d}" for t in zip(quarter, year)] + strs = [f"{t[0]:d}Q{t[1]:d}" for t in zip(quarter, year, strict=True)] lops = list(map(Period, strs)) p = PeriodIndex(lops) tm.assert_index_equal(p, idx) diff --git a/pandas/tests/indexes/period/test_formats.py b/pandas/tests/indexes/period/test_formats.py index dc95e19523842..7d2733aeefe86 100644 --- a/pandas/tests/indexes/period/test_formats.py +++ b/pandas/tests/indexes/period/test_formats.py @@ -83,7 +83,7 @@ def test_representation(self, method): for idx, expected in zip( [idx1, idx2, idx3, idx4, idx5, idx6, idx7, idx8, idx9, idx10], - [exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9, exp10], + [exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9, exp10], strict=True, ): result = getattr(idx, method)() assert result == expected @@ -140,7 +140,7 @@ def test_representation_to_series(self): for idx, expected in zip( [idx1, idx2, idx3, idx4, idx5, idx6, idx7, idx8, idx9], - [exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9], + [exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9], strict=True, ): result = repr(Series(idx)) assert result == expected @@ -187,7 +187,7 @@ def test_summary(self): for idx, expected in zip( [idx1, idx2, idx3, idx4, idx5, idx6, idx7, idx8, idx9], - [exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9], + [exp1, exp2, exp3, exp4, exp5, exp6, exp7, exp8, exp9], strict=True, ): result = idx._summary() assert result == expected diff --git a/pandas/tests/indexes/period/test_period.py b/pandas/tests/indexes/period/test_period.py index d465225da7f24..57822abb19227 100644 --- a/pandas/tests/indexes/period/test_period.py +++ b/pandas/tests/indexes/period/test_period.py @@ -102,7 +102,7 @@ def test_fields(self, periodindex, field): field_idx = getattr(periodindex, field) assert len(periodindex) == len(field_idx) - for x, val in zip(periods, field_idx): + for x, val in zip(periods, field_idx, strict=True): assert getattr(x, field) == val if len(ser) == 0: @@ -110,7 +110,7 @@ def test_fields(self, periodindex, field): field_s = getattr(ser.dt, field) assert len(periodindex) == len(field_s) - for x, val in zip(periods, field_s): + for x, val in zip(periods, field_s, strict=True): assert getattr(x, field) == val def test_is_(self): diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 26eb33195ccbc..0c7f9dc8d0bf4 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -534,7 +534,7 @@ def test_map_with_tuples_mi(self): # Test that returning a single object from a MultiIndex # returns an Index. first_level = ["foo", "bar", "baz"] - multi_index = MultiIndex.from_tuples(zip(first_level, [1, 2, 3])) + multi_index = MultiIndex.from_tuples(zip(first_level, [1, 2, 3], strict=True)) reduced_index = multi_index.map(lambda x: x[0]) tm.assert_index_equal(reduced_index, Index(first_level)) @@ -562,7 +562,7 @@ def test_map_tseries_indices_accsr_return_index(self): @pytest.mark.parametrize( "mapper", [ - lambda values, index: {i: e for e, i in zip(values, index)}, + lambda values, index: {i: e for e, i in zip(values, index, strict=True)}, lambda values, index: Series(values, index), ], ) @@ -576,7 +576,7 @@ def test_map_dictlike_simple(self, mapper): @pytest.mark.parametrize( "mapper", [ - lambda values, index: {i: e for e, i in zip(values, index)}, + lambda values, index: {i: e for e, i in zip(values, index, strict=True)}, lambda values, index: Series(values, index), ], ) diff --git a/pandas/tests/indexes/test_datetimelike.py b/pandas/tests/indexes/test_datetimelike.py index e45d11e6286e2..c22beacb008c9 100644 --- a/pandas/tests/indexes/test_datetimelike.py +++ b/pandas/tests/indexes/test_datetimelike.py @@ -109,7 +109,7 @@ def test_map_callable(self, simple_index): @pytest.mark.parametrize( "mapper", [ - lambda values, index: {i: e for e, i in zip(values, index)}, + lambda values, index: {i: e for e, i in zip(values, index, strict=True)}, lambda values, index: pd.Series(values, index, dtype=object), ], ) diff --git a/pandas/tests/indexes/test_old_base.py b/pandas/tests/indexes/test_old_base.py index f4e83a87bf278..9f8cdb6197c62 100644 --- a/pandas/tests/indexes/test_old_base.py +++ b/pandas/tests/indexes/test_old_base.py @@ -669,7 +669,7 @@ def test_map(self, simple_index): @pytest.mark.parametrize( "mapper", [ - lambda values, index: {i: e for e, i in zip(values, index)}, + lambda values, index: {i: e for e, i in zip(values, index, strict=True)}, lambda values, index: Series(values, index), ], ) diff --git a/pandas/tests/indexes/test_setops.py b/pandas/tests/indexes/test_setops.py index 6922803c325b3..dbc9f49799f95 100644 --- a/pandas/tests/indexes/test_setops.py +++ b/pandas/tests/indexes/test_setops.py @@ -914,7 +914,7 @@ def test_difference_incomparable_true(self, opname): op(a) def test_symmetric_difference_mi(self, sort): - index1 = MultiIndex.from_tuples(zip(["foo", "bar", "baz"], [1, 2, 3])) + index1 = MultiIndex.from_tuples(zip(["foo", "bar", "baz"], [1, 2, 3], strict=True)) index2 = MultiIndex.from_tuples([("foo", 1), ("bar", 3)]) result = index1.symmetric_difference(index2, sort=sort) expected = MultiIndex.from_tuples([("bar", 2), ("baz", 3), ("bar", 3)]) diff --git a/pandas/tests/indexes/timedeltas/test_formats.py b/pandas/tests/indexes/timedeltas/test_formats.py index 607336060cbbc..ea44f7f7210ba 100644 --- a/pandas/tests/indexes/timedeltas/test_formats.py +++ b/pandas/tests/indexes/timedeltas/test_formats.py @@ -46,7 +46,7 @@ def test_representation(self, method): with pd.option_context("display.width", 300): for idx, expected in zip( - [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5] + [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5], strict=True ): result = getattr(idx, method)() assert result == expected @@ -76,7 +76,7 @@ def test_representation_to_series(self): with pd.option_context("display.width", 300): for idx, expected in zip( - [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5] + [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5], strict=True ): result = repr(Series(idx)) assert result == expected @@ -100,7 +100,7 @@ def test_summary(self): exp5 = "TimedeltaIndex: 3 entries, 1 days 00:00:01 to 3 days 00:00:00" for idx, expected in zip( - [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5] + [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5], strict=True ): result = idx._summary() assert result == expected From c78b3d12c5da8205cc51697d8b510f06328ef293 Mon Sep 17 00:00:00 2001 From: Minh Date: Mon, 6 Oct 2025 20:28:18 -0400 Subject: [PATCH 2/2] STY: fix long lines to satisfy Ruff E501 --- pandas/tests/indexes/datetimes/test_formats.py | 3 ++- pandas/tests/indexes/datetimes/test_scalar_compat.py | 3 ++- pandas/tests/indexes/test_setops.py | 3 ++- pandas/tests/indexes/timedeltas/test_formats.py | 6 ++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pandas/tests/indexes/datetimes/test_formats.py b/pandas/tests/indexes/datetimes/test_formats.py index 88301878b5ed5..166abf17b4ced 100644 --- a/pandas/tests/indexes/datetimes/test_formats.py +++ b/pandas/tests/indexes/datetimes/test_formats.py @@ -264,7 +264,8 @@ def test_dti_summary(self): exp6 = """DatetimeIndex: 3 entries, 2011-01-01 09:00:00-05:00 to NaT""" for idx, expected in zip( - [idx1, idx2, idx3, idx4, idx5, idx6], [exp1, exp2, exp3, exp4, exp5, exp6], strict=True + [idx1, idx2, idx3, idx4, idx5, idx6], [exp1, exp2, exp3, exp4, exp5, exp6] + , strict=True ): result = idx._summary() assert result == expected diff --git a/pandas/tests/indexes/datetimes/test_scalar_compat.py b/pandas/tests/indexes/datetimes/test_scalar_compat.py index c43799dcaa9c5..43a5b75ca135a 100644 --- a/pandas/tests/indexes/datetimes/test_scalar_compat.py +++ b/pandas/tests/indexes/datetimes/test_scalar_compat.py @@ -184,7 +184,8 @@ def test_day_name_month_name(self, time_locale): "Saturday", "Sunday", ] - for day, name, eng_name in zip(range(4, 11), expected_days, english_days, strict=True): + for day, name, eng_name in zip(range(4, 11), expected_days, english_days, + strict=True): name = name.capitalize() assert dti.day_name(locale=time_locale)[day] == name assert dti.day_name(locale=None)[day] == eng_name diff --git a/pandas/tests/indexes/test_setops.py b/pandas/tests/indexes/test_setops.py index dbc9f49799f95..19309c72efe35 100644 --- a/pandas/tests/indexes/test_setops.py +++ b/pandas/tests/indexes/test_setops.py @@ -914,7 +914,8 @@ def test_difference_incomparable_true(self, opname): op(a) def test_symmetric_difference_mi(self, sort): - index1 = MultiIndex.from_tuples(zip(["foo", "bar", "baz"], [1, 2, 3], strict=True)) + index1 = MultiIndex.from_tuples(zip(["foo", "bar", "baz"], [1, 2, 3], + strict=True)) index2 = MultiIndex.from_tuples([("foo", 1), ("bar", 3)]) result = index1.symmetric_difference(index2, sort=sort) expected = MultiIndex.from_tuples([("bar", 2), ("baz", 3), ("bar", 3)]) diff --git a/pandas/tests/indexes/timedeltas/test_formats.py b/pandas/tests/indexes/timedeltas/test_formats.py index ea44f7f7210ba..3f96dacea4319 100644 --- a/pandas/tests/indexes/timedeltas/test_formats.py +++ b/pandas/tests/indexes/timedeltas/test_formats.py @@ -46,7 +46,8 @@ def test_representation(self, method): with pd.option_context("display.width", 300): for idx, expected in zip( - [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5], strict=True + [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5], + strict=True ): result = getattr(idx, method)() assert result == expected @@ -76,7 +77,8 @@ def test_representation_to_series(self): with pd.option_context("display.width", 300): for idx, expected in zip( - [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5], strict=True + [idx1, idx2, idx3, idx4, idx5], [exp1, exp2, exp3, exp4, exp5], + strict=True ): result = repr(Series(idx)) assert result == expected