From f6302aeebbb6c28345c4de6fda37300f7f3420ef Mon Sep 17 00:00:00 2001 From: majiayu000 <1835304752@qq.com> Date: Sun, 14 Dec 2025 00:51:49 +0800 Subject: [PATCH] STY: Add explicit strict= to zip() calls in pandas/tests/strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add strict=True or strict=False to all zip() calls in pandas/tests/strings/ to comply with Ruff rule B905 (zip-without-explicit-strict). - conftest.py: Add strict=False for intentionally unequal length zip, strict=True for equal length unpack - test_api.py: Add strict=True for equal length unpack - test_strings.py: Add strict=True for equal length strings Partial fix for #62434 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- pandas/tests/strings/conftest.py | 3 ++- pandas/tests/strings/test_api.py | 2 +- pandas/tests/strings/test_strings.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/tests/strings/conftest.py b/pandas/tests/strings/conftest.py index 5bcbb16da3be9..122bebb517c9a 100644 --- a/pandas/tests/strings/conftest.py +++ b/pandas/tests/strings/conftest.py @@ -94,9 +94,10 @@ ], [()] * 100, [{}] * 100, + strict=False, ) ) -ids, _, _ = zip(*_any_string_method) # use method name as fixture-id +ids, _, _ = zip(*_any_string_method, strict=True) # use method name as fixture-id missing_methods = {f for f in dir(StringMethods) if not f.startswith("_")} - set(ids) # test that the above list captures all methods of StringMethods diff --git a/pandas/tests/strings/test_api.py b/pandas/tests/strings/test_api.py index 6b9df072019eb..470ece15fa536 100644 --- a/pandas/tests/strings/test_api.py +++ b/pandas/tests/strings/test_api.py @@ -21,7 +21,7 @@ ("empty", []), ("mixed-integer", ["a", np.nan, 2]), ] -ids, _ = zip(*_any_allowed_skipna_inferred_dtype) # use inferred type as id +ids, _ = zip(*_any_allowed_skipna_inferred_dtype, strict=True) # use inferred type as id @pytest.fixture(params=_any_allowed_skipna_inferred_dtype, ids=ids) diff --git a/pandas/tests/strings/test_strings.py b/pandas/tests/strings/test_strings.py index e07ece91090df..2ca5838283943 100644 --- a/pandas/tests/strings/test_strings.py +++ b/pandas/tests/strings/test_strings.py @@ -757,7 +757,7 @@ def test_cat_on_bytes_raises(): def test_str_accessor_in_apply_func(): # https://github.com/pandas-dev/pandas/issues/38979 - df = DataFrame(zip("abc", "def")) + df = DataFrame(zip("abc", "def", strict=True)) expected = Series(["A/D", "B/E", "C/F"]) result = df.apply(lambda f: "/".join(f.str.upper()), axis=1) tm.assert_series_equal(result, expected)