Skip to content

Conversation

RAAPPO
Copy link
Contributor

@RAAPPO RAAPPO commented Oct 3, 2025

Part of #62434

This PR enforces Ruff rule B905 (zip-without-explicit-strict) across the pandas test suite by adding strict=True to all relevant zip() calls in pandas/tests.

  • Updated all occurrences of zip(...) in test files to use zip(..., strict=True) where appropriate.
  • Fixed any syntax errors and line length issues related to these changes.
  • Ensured all code checks and pre-commit hooks pass after modifications.
  • Verified that tests still run successfully after these changes.

Checklist:

  • Part of STY: Enforce Ruff rule B905, zip-without-explicit-strict #62434
  • All code checks passed.
  • Tests added and passed if fixing a bug or adding a new feature.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Please let me know if any changes are needed!

@RAAPPO RAAPPO marked this pull request as ready for review October 4, 2025 10:06
Copy link
Contributor

@Alvaro-Kothe Alvaro-Kothe left a comment

Choose a reason for hiding this comment

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

Remove the files you modified from pyproject.toml.

if isinstance(key, np.ndarray) and key.dtype == "bool":
# masking
for i, (k, v) in enumerate(zip(key, value)):
for i, (k, v) in enumerate(zip(key, value, strict=False)):
Copy link
Contributor

Choose a reason for hiding this comment

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

When value is assigned to cycle it should be strict=False otherwise, I think it can be strict=True.

self.data[i] = v
else:
for k, v in zip(key, value):
for k, v in zip(key, value, strict=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

# non-unique - wheee!
nu_df = DataFrame(
list(zip(range(3), range(-3, 1), list("abc"))), columns=["a", "a", "b"]
list(zip(range(3), range(-3, 1), list("abc"), strict=False)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
list(zip(range(3), range(-3, 1), list("abc"), strict=False)),
list(zip(range(3), range(-3, 0), list("abc"), strict=True)),

result = gb.apply(lambda grp: pd.DataFrame({"values": range(len(grp))}))

mi_tuples = tuple(zip(data["groups"], selected_data["values"]))
mi_tuples = tuple(zip(data["groups"], selected_data["values"], strict=False))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this False?

expecteds = [DataFrame(values, index=index) for (values, index) in expected]

for expected, actual in zip(expecteds, df.expanding(min_periods)):
for expected, actual in zip(expecteds, df.expanding(min_periods), strict=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

Which test cases require this to be marked as False?


for expected, actual in zip(expecteds, df.rolling(window, min_periods=min_periods)):
for expected, actual in zip(
expecteds, df.rolling(window, min_periods=min_periods), strict=False
Copy link
Contributor

Choose a reason for hiding this comment

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

Which test cases require this to be marked as False?

DataFrame(values, index=df.loc[index, "C"]) for (values, index) in expected
]
for expected, actual in zip(expecteds, df.rolling(window, on="C")):
for expected, actual in zip(expecteds, df.rolling(window, on="C"), strict=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

Which test cases require this to be marked as False?

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.

2 participants