Skip to content

Commit 1863adb

Browse files
authored
STY: add strict=True to builtin zip() calls in pandas/tests/indexes/multi (#62634)
1 parent bfb740a commit 1863adb

File tree

5 files changed

+7
-11
lines changed

5 files changed

+7
-11
lines changed

pandas/tests/indexes/multi/test_analytics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_map(idx):
185185
@pytest.mark.parametrize(
186186
"mapper",
187187
[
188-
lambda values, idx: {i: e for e, i in zip(values, idx)},
188+
lambda values, idx: {i: e for e, i in zip(values, idx, strict=True)},
189189
lambda values, idx: pd.Series(values, idx),
190190
],
191191
)

pandas/tests/indexes/multi/test_constructors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_copy_in_constructor():
155155
def test_from_arrays(idx):
156156
arrays = [
157157
np.asarray(lev).take(level_codes)
158-
for lev, level_codes in zip(idx.levels, idx.codes)
158+
for lev, level_codes in zip(idx.levels, idx.codes, strict=True)
159159
]
160160

161161
# list of arrays as input
@@ -172,7 +172,7 @@ def test_from_arrays_iterator(idx):
172172
# GH 18434
173173
arrays = [
174174
np.asarray(lev).take(level_codes)
175-
for lev, level_codes in zip(idx.levels, idx.codes)
175+
for lev, level_codes in zip(idx.levels, idx.codes, strict=True)
176176
]
177177

178178
# iterator as input
@@ -188,7 +188,7 @@ def test_from_arrays_iterator(idx):
188188
def test_from_arrays_tuples(idx):
189189
arrays = tuple(
190190
tuple(np.asarray(lev).take(level_codes))
191-
for lev, level_codes in zip(idx.levels, idx.codes)
191+
for lev, level_codes in zip(idx.levels, idx.codes, strict=True)
192192
)
193193

194194
# tuple of tuples as input
@@ -368,7 +368,7 @@ def test_from_tuples_iterator():
368368
levels=[[1, 3], [2, 4]], codes=[[0, 1], [0, 1]], names=["a", "b"]
369369
)
370370

371-
result = MultiIndex.from_tuples(zip([1, 3], [2, 4]), names=["a", "b"])
371+
result = MultiIndex.from_tuples(zip([1, 3], [2, 4], strict=True), names=["a", "b"])
372372
tm.assert_index_equal(result, expected)
373373

374374
# input non-iterables

pandas/tests/indexes/multi/test_equivalence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def test_equals_missing_values_differently_sorted():
223223

224224

225225
def test_is_():
226-
mi = MultiIndex.from_tuples(zip(range(10), range(10)))
226+
mi = MultiIndex.from_tuples(zip(range(10), range(10), strict=True))
227227
assert mi.is_(mi)
228228
assert mi.is_(mi.view())
229229
assert mi.is_(mi.view().view().view().view())

pandas/tests/indexes/multi/test_get_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def assert_matching(actual, expected, check_dtype=False):
1515
# avoid specifying internal representation
1616
# as much as possible
1717
assert len(actual) == len(expected)
18-
for act, exp in zip(actual, expected):
18+
for act, exp in zip(actual, expected, strict=True):
1919
act = np.asarray(act)
2020
exp = np.asarray(exp)
2121
tm.assert_numpy_array_equal(act, exp, check_dtype=check_dtype)

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,6 @@ exclude = [
520520
"pandas/tests/indexes/interval/test_constructors.py" = ["B905"]
521521
"pandas/tests/indexes/interval/test_formats.py" = ["B905"]
522522
"pandas/tests/indexes/interval/test_interval.py" = ["B905"]
523-
"pandas/tests/indexes/multi/test_analytics.py" = ["B905"]
524-
"pandas/tests/indexes/multi/test_constructors.py" = ["B905"]
525-
"pandas/tests/indexes/multi/test_equivalence.py" = ["B905"]
526-
"pandas/tests/indexes/multi/test_get_set.py" = ["B905"]
527523
"pandas/tests/indexes/period/methods/test_asfreq.py" = ["B905"]
528524
"pandas/tests/indexes/period/test_constructors.py" = ["B905"]
529525
"pandas/tests/indexes/period/test_formats.py" = ["B905"]

0 commit comments

Comments
 (0)