Skip to content

Commit f6302ae

Browse files
majiayu000claude
andcommitted
STY: Add explicit strict= to zip() calls in pandas/tests/strings
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 <noreply@anthropic.com>
1 parent 1fd184d commit f6302ae

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

pandas/tests/strings/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@
9494
],
9595
[()] * 100,
9696
[{}] * 100,
97+
strict=False,
9798
)
9899
)
99-
ids, _, _ = zip(*_any_string_method) # use method name as fixture-id
100+
ids, _, _ = zip(*_any_string_method, strict=True) # use method name as fixture-id
100101
missing_methods = {f for f in dir(StringMethods) if not f.startswith("_")} - set(ids)
101102

102103
# test that the above list captures all methods of StringMethods

pandas/tests/strings/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
("empty", []),
2222
("mixed-integer", ["a", np.nan, 2]),
2323
]
24-
ids, _ = zip(*_any_allowed_skipna_inferred_dtype) # use inferred type as id
24+
ids, _ = zip(*_any_allowed_skipna_inferred_dtype, strict=True) # use inferred type as id
2525

2626

2727
@pytest.fixture(params=_any_allowed_skipna_inferred_dtype, ids=ids)

pandas/tests/strings/test_strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def test_cat_on_bytes_raises():
757757

758758
def test_str_accessor_in_apply_func():
759759
# https://github.com/pandas-dev/pandas/issues/38979
760-
df = DataFrame(zip("abc", "def"))
760+
df = DataFrame(zip("abc", "def", strict=True))
761761
expected = Series(["A/D", "B/E", "C/F"])
762762
result = df.apply(lambda f: "/".join(f.str.upper()), axis=1)
763763
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)