Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Zip Strict for pandas/core level files #62469 #62577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
mroeschke merged 3 commits into pandas-dev:main from shivamvishal:main
Oct 4, 2025

Conversation

Copy link
Contributor

@shivamvishal shivamvishal commented Oct 4, 2025

@Copilot Copilot AI review requested due to automatic review settings October 4, 2025 12:11
Copy link

@Copilot 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 addresses issue #62434 by adding strict=True to all zip() calls in pandas core level files to enable "zip strict" mode. This change ensures that zip operations explicitly validate that all iterables have the same length, helping catch potential bugs where mismatched lengths could cause silent data corruption or incorrect results.

Key Changes:

  • Modified all zip() calls in core pandas files to use strict=True parameter
  • Removed corresponding entries from the B905 exclusion list in pyproject.toml
  • One exception uses strict=False where intentional length mismatch is expected

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Removed B905 exclusion entries for core files now using strict zip
pandas/core/sorting.py Added strict=True to zip calls in sorting operations
pandas/core/series.py Added strict=True to zip calls in Series methods
pandas/core/indexing.py Added strict=True to zip calls with one intentional strict=False
pandas/core/generic.py Added strict=True to zip calls in generic DataFrame/Series operations
pandas/core/frame.py Added strict=True to zip calls with one intentional strict=False
pandas/core/arraylike.py Added strict=True to zip calls in array operations
pandas/core/apply.py Added strict=True to zip calls in apply operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


if not isinstance(indexer, tuple):
indexer = _tuplify(self.ndim, indexer)

Copy link
Preview

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a comment explaining why strict=False is intentionally used here, as it's the only exception to the strict zip pattern in this PR.

Suggested change
# Intentionally use strict=False here: in some cases, indexer may be shorter or longer
# than self.obj.axes, and we want to ignore any extra elements rather than raise an error.
# This is the only exception to the strict zip pattern in this codebase.

Copilot uses AI. Check for mistakes.

# never try to overwrite values inplace

if isinstance(value, DataFrame):
check_key_length(self.columns, key, value)
Copy link
Preview

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a comment explaining why strict=False is intentionally used here, as it deviates from the strict zip pattern being implemented throughout the codebase.

Suggested change
check_key_length(self.columns, key, value)
check_key_length(self.columns, key, value)
# Intentionally use strict=False: key and value.columns may differ in length,
# and we only want to assign for the overlapping pairs. This deviates from the
# usual strict zip pattern in the codebase.

Copilot uses AI. Check for mistakes.

"pandas/tests/window/test_expanding.py" = ["B905"]
"pandas/tests/window/test_rolling.py" = ["B905"]
"pandas/util/_doctools.py" = ["B905"]
"pandas/util/_validators.py" = ["B905"]
Copy link
Contributor Author

@shivamvishal shivamvishal Oct 4, 2025

Choose a reason for hiding this comment

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

missed clean up in previous PR: #62540

@mroeschke mroeschke added the Code Style Code style, linting, code_checks label Oct 4, 2025
@mroeschke mroeschke added this to the 3.0 milestone Oct 4, 2025
@mroeschke mroeschke merged commit 54b8f29 into pandas-dev:main Oct 4, 2025
45 checks passed
Copy link
Member

Thanks @shivamvishal

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

Copilot code review Copilot Copilot left review comments

@mroeschke mroeschke mroeschke approved these changes

Assignees
No one assigned
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Milestone
3.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /