STY: Add strict=True to zip() calls in pandas/tests/reshape #63228
+7
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
STY: Add strict=True to zip() calls in pandas/tests/reshape
Description
This PR enforces Ruff rule B905 (
zip-without-explicit-strict) for thepandas/tests/reshapedirectory by addingstrict=Trueto allzip()calls.Changes Made
Modified the following test files to add
strict=Trueparameter tozip()calls:pandas/tests/reshape/concat/test_concat.py(1 occurrence)pandas/tests/reshape/concat/test_index.py(2 occurrences)pandas/tests/reshape/test_melt.py(3 occurrences)pandas/tests/reshape/test_qcut.py(1 occurrence)Total: 7 zip() calls updated
Rationale
Using
strict=Truemakes zip() raise aValueErrorif the input iterables have different lengths, which helps catch bugs early. Most zip() calls in pandas have an underlying assumption that input arguments are of equal length, and this change makes that assumption explicit and runtime-verified.Related Issue
Contributes to #62434
Testing
All existing tests in the modified files pass with the changes. The
strict=Trueparameter was chosen because:Files Changed
Directory Status
This PR completes the enforcement of B905 for the
pandas/tests/reshapedirectory. Allzip()calls in this directory now have explicitstrictparameters.Notes
pyproject.toml