Skip to content

Conversation

@AKHIL-149
Copy link

I added the strict=True parameter to 11 zip() calls across 7 files in the pandas/tests/extension directory to enforce Ruff rule B905.

Changes made:

  • base/methods.py: 3 zip() calls (lines 353, 372, 630)
  • date/array.py: 1 zip() call (line 165)
  • decimal/array.py: 1 zip() call (line 298)
  • json/array.py: 3 zip() calls (lines 131, 149, 154)
  • test_arrow.py: 1 zip() call (line 285)
  • test_categorical.py: 1 zip() call (line 129)
  • test_interval.py: 1 zip() call (line 37)

This ensures that all zipped iterables have equal lengths, making the tests more robust and catching potential bugs early during testing.


Checklist:

  • closes STY: Enforce Ruff rule B905, zip-without-explicit-strict #62434
  • Tests added and passed if fixing a bug or adding a new feature - N/A: Style fix, existing tests validate the change
  • All code checks passed
  • Added type annotations to new arguments/methods/functions - N/A: No new code added
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature - N/A: Style fix doesn't require whatsnew entry
  • If I used AI to develop this pull request, I prompted it to follow AGENTS.md - N/A: Manual code changes

I added strict=True parameter to 11 zip() calls across 7 files in the
pandas/tests/extension directory to enforce Ruff rule B905.

This ensures that all zipped iterables have equal lengths, making the
tests more robust and catching potential bugs early during testing.

Files modified:
- base/methods.py: 3 zip() calls
- date/array.py: 1 zip() call
- decimal/array.py: 1 zip() call
- json/array.py: 3 zip() calls
- test_arrow.py: 1 zip() call
- test_categorical.py: 1 zip() call
- test_interval.py: 1 zip() call
I changed two zip() calls in json/array.py from strict=True to strict=False
because the 'value' variable can be an itertools.cycle() iterator (line 145),
which is infinite. You cannot use strict=True with infinite iterators as they
don't have a defined length to compare.

Lines changed:
- Line 149: enumerate(zip(key, value, strict=False))
- Line 154: zip(key, value, strict=False)
I broke long lines into multiple lines to comply with the 88-character
line length limit enforced by ruff.

Files fixed:
- base/methods.py:353 - Split list comprehension with zip across multiple lines
- test_interval.py:37 - Split list comprehension with zip across multiple lines

This addresses the pre-commit.ci E501 failures.
@AKHIL-149
Copy link
Author

pre-commit.ci autofix

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.

STY: Enforce Ruff rule B905, zip-without-explicit-strict

1 participant