Skip to content

Conversation

invain01
Copy link
Contributor

@invain01 invain01 commented Oct 5, 2025

Summary

This change enforces Ruff rule B905 (zip-without-explicit-strict) by adding strict=True to all zip() function calls in pandas/core/methods/to_dict.py. This ensures that input iterables are of equal length, preventing silent truncation and potential data inconsistencies.

Modified File

  • pandas/core/methods/to_dict.py

Specific Changes

The following 6 zip() calls were updated to include strict=True:

  1. Line 201: zip(box_na_values, df.items())zip(box_na_values, df.items(), strict=True)
  2. Line 238: zip(columns, map(maybe_box_native, row))zip(columns, map(maybe_box_native, row), strict=True)
  3. Line 243: zip(columns, t)zip(columns, t, strict=True)
  4. Line 263: zip(df.columns, map(maybe_box_native, t[1:]))zip(df.columns, map(maybe_box_native, t[1:]), strict=True)
  5. Line 275: zip(columns, t[1:])zip(columns, t[1:], strict=True)
  6. Line 282: zip(columns, t[1:])zip(columns, t[1:], strict=True)

@invain01
Copy link
Contributor Author

invain01 commented Oct 5, 2025

pre-commit.ci autofix

@mroeschke mroeschke added the Code Style Code style, linting, code_checks label Oct 5, 2025
@mroeschke mroeschke added this to the 3.0 milestone Oct 5, 2025
@mroeschke mroeschke merged commit 3c17066 into pandas-dev:main Oct 5, 2025
46 checks passed
@mroeschke
Copy link
Member

Thanks @invain01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants