Skip to content

Conversation

@Ghazi-raad
Copy link

STY: Add strict=True to zip() calls in pandas/tests/reshape

Description

This PR enforces Ruff rule B905 (zip-without-explicit-strict) for the pandas/tests/reshape directory by adding strict=True to all zip() calls.

Changes Made

Modified the following test files to add strict=True parameter to zip() 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=True makes zip() raise a ValueError if 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=True parameter was chosen because:

  • All modified zip() calls iterate over collections that are expected to have matching lengths
  • This is a test file change with no runtime impact on pandas library code
  • Enforcing strict equality helps catch test logic errors

Files Changed

pandas/tests/reshape/concat/test_concat.py
pandas/tests/reshape/concat/test_index.py
pandas/tests/reshape/test_melt.py
pandas/tests/reshape/test_qcut.py

Directory Status

This PR completes the enforcement of B905 for the pandas/tests/reshape directory. All zip() calls in this directory now have explicit strict parameters.

Notes

  • This is part of the larger effort to enforce Ruff rule B905 across the entire pandas codebase
  • Once all directories are updated, a separate PR will enable the B905 rule in pyproject.toml
  • Changes are minimal and focused on code style improvement with no functional changes to test logic

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 pandas-dev#62434
Copilot AI review requested due to automatic review settings November 28, 2025 19:04
Copilot finished reviewing on behalf of Ghazi-raad November 28, 2025 19:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enforces Ruff rule B905 (zip-without-explicit-strict) for the pandas/tests/reshape directory by adding strict=True to all zip() calls in test files. This is part of a broader codebase-wide effort to make implicit assumptions about equal-length iterables explicit and runtime-verified.

Key Changes:

  • Added strict=True parameter to 7 zip() calls across 4 test files
  • No functional changes to test logic, only defensive programming improvements
  • All modified zip() calls operate on iterables with guaranteed equal lengths

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pandas/tests/reshape/test_qcut.py Added strict=True to 1 zip() call iterating over qcut results
pandas/tests/reshape/test_melt.py Added strict=True to 3 zip() calls creating test dictionaries with range(3) and 3-element arrays
pandas/tests/reshape/concat/test_index.py Added strict=True to 2 zip() calls: one creating test DataFrames and one creating MultiIndex tuples
pandas/tests/reshape/concat/test_concat.py Added strict=True to 1 zip() call creating MultiIndex tuples for expected test results

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant