From a481e236665743cd1f0cd517e25d44f43ce056b9 Mon Sep 17 00:00:00 2001 From: BreezeLune <1066773178@qq.com> Date: Tue, 14 Oct 2025 02:37:51 +0800 Subject: [PATCH 1/2] STY: Add strict=True to zip() calls in pandas/_testing - Add explicit strict=True to zip() calls in pandas/_testing/asserters.py (2 calls) - Add explicit strict=True to zip() calls in pandas/_testing/_warnings.py (1 call) - Satisfies Ruff rule B905 (zip-without-explicit-strict) Towards #62434 --- pandas/_testing/_warnings.py | 2 +- pandas/_testing/asserters.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_testing/_warnings.py b/pandas/_testing/_warnings.py index 6ed8a7b9154d4..2aa891703ce23 100644 --- a/pandas/_testing/_warnings.py +++ b/pandas/_testing/_warnings.py @@ -110,7 +110,7 @@ class for all warnings. To raise multiple types of exceptions, if isinstance(match, tuple) else (match,) * len(expected_warning) ) - for warning_type, warning_match in zip(expected_warning, match): + for warning_type, warning_match in zip(expected_warning, match, strict=True): _assert_caught_expected_warnings( caught_warnings=w, expected_warning=warning_type, diff --git a/pandas/_testing/asserters.py b/pandas/_testing/asserters.py index c8f3bb6bd77d2..fc2cae5fadaa7 100644 --- a/pandas/_testing/asserters.py +++ b/pandas/_testing/asserters.py @@ -675,7 +675,7 @@ def _raise(left, right, err_msg) -> NoReturn: ) diff = 0 - for left_arr, right_arr in zip(left, right): + for left_arr, right_arr in zip(left, right, strict=True): # count up differences if not array_equivalent(left_arr, right_arr, strict_nan=strict_nan): diff += 1 @@ -1447,7 +1447,7 @@ def assert_copy(iter1, iter2, **eql_kwargs) -> None: the same object. (Does not check that items in sequences are also not the same object) """ - for elem1, elem2 in zip(iter1, iter2): + for elem1, elem2 in zip(iter1, iter2, strict=True): assert_almost_equal(elem1, elem2, **eql_kwargs) msg = ( f"Expected object {type(elem1)!r} and object {type(elem2)!r} to be " From d2cdeb6f7f0380f78bb66ae539cc45344c117286 Mon Sep 17 00:00:00 2001 From: BreezeLune <1066773178@qq.com> Date: Tue, 14 Oct 2025 06:03:06 +0800 Subject: [PATCH 2/2] Fix line length in _warnings.py to satisfy ruff format --- pandas/_testing/_warnings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/_testing/_warnings.py b/pandas/_testing/_warnings.py index 2aa891703ce23..d2d1f5c0c273e 100644 --- a/pandas/_testing/_warnings.py +++ b/pandas/_testing/_warnings.py @@ -110,7 +110,9 @@ class for all warnings. To raise multiple types of exceptions, if isinstance(match, tuple) else (match,) * len(expected_warning) ) - for warning_type, warning_match in zip(expected_warning, match, strict=True): + for warning_type, warning_match in zip( + expected_warning, match, strict=True + ): _assert_caught_expected_warnings( caught_warnings=w, expected_warning=warning_type,