Skip to content

Commit 86fe79b

Browse files
committed
STY: Add strict=True to zip() calls in pandas/tests/reshape
This commit enforces Ruff rule B905 (zip-without-explicit-strict) for the pandas/tests/reshape directory. All zip() calls now explicitly specify strict=True to ensure equal-length iterator assumptions are validated at runtime. Related to issue #62434
1 parent 1b5b02c commit 86fe79b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

pandas/tests/reshape/concat/test_concat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def test_concat_repeated_keys(keys, integrity):
707707
# GH: 20816
708708
series_list = [Series({"a": 1}), Series({"b": 2}), Series({"c": 3})]
709709
result = concat(series_list, keys=keys, verify_integrity=integrity)
710-
tuples = list(zip(keys, ["a", "b", "c"]))
710+
tuples = list(zip(keys, ["a", "b", "c"], strict=True))
711711
expected = Series([1, 2, 3], index=MultiIndex.from_tuples(tuples))
712712
tm.assert_series_equal(result, expected)
713713

pandas/tests/reshape/concat/test_index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_concat_same_index_names(self, name_in1, name_in2, name_in3, name_out):
6060
Index(["c", "d", "e"], name=name_in3),
6161
]
6262
frames = [
63-
DataFrame({c: [0, 1, 2]}, index=i) for i, c in zip(indices, ["x", "y", "z"])
63+
DataFrame({c: [0, 1, 2]}, index=i) for i, c in zip(indices, ["x", "y", "z"], strict=True)
6464
]
6565
result = concat(frames, axis=1)
6666

@@ -218,7 +218,7 @@ def test_concat_multiindex_with_none_in_index_names(self):
218218
level2 = [1] * 5 + [2] * 2
219219
level1 = [1] * 7
220220
no_name = list(range(5)) + list(range(2))
221-
tuples = list(zip(level2, level1, no_name))
221+
tuples = list(zip(level2, level1, no_name, strict=True))
222222
index = MultiIndex.from_tuples(tuples, names=["level2", "level1", None])
223223
expected = DataFrame({"col": no_name}, index=index, dtype=np.int32)
224224
tm.assert_frame_equal(result, expected)

pandas/tests/reshape/test_melt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ def test_simple(self):
801801
"A1980": {0: "d", 1: "e", 2: "f"},
802802
"B1970": {0: 2.5, 1: 1.2, 2: 0.7},
803803
"B1980": {0: 3.2, 1: 1.3, 2: 0.1},
804-
"X": dict(zip(range(3), x)),
804+
"X": dict(zip(range(3), x, strict=True)),
805805
}
806806
)
807807
df["id"] = df.index
@@ -837,7 +837,7 @@ def test_separating_character(self):
837837
"A.1980": {0: "d", 1: "e", 2: "f"},
838838
"B.1970": {0: 2.5, 1: 1.2, 2: 0.7},
839839
"B.1980": {0: 3.2, 1: 1.3, 2: 0.1},
840-
"X": dict(zip(range(3), x)),
840+
"X": dict(zip(range(3), x, strict=True)),
841841
}
842842
)
843843
df["id"] = df.index
@@ -861,7 +861,7 @@ def test_escapable_characters(self):
861861
"A(quarterly)1980": {0: "d", 1: "e", 2: "f"},
862862
"B(quarterly)1970": {0: 2.5, 1: 1.2, 2: 0.7},
863863
"B(quarterly)1980": {0: 3.2, 1: 1.3, 2: 0.1},
864-
"X": dict(zip(range(3), x)),
864+
"X": dict(zip(range(3), x, strict=True)),
865865
}
866866
)
867867
df["id"] = df.index

pandas/tests/reshape/test_qcut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,5 @@ def test_qcut_contains(scale, q, precision):
304304
arr = (scale * np.arange(q + 1)).round(precision)
305305
result = qcut(arr, q, precision=precision)
306306

307-
for value, bucket in zip(arr, result):
307+
for value, bucket in zip(arr, result, strict=True):
308308
assert value in bucket

0 commit comments

Comments
 (0)