-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
STY: ZIP strict for pandas/io #62469
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fix the problem.
Also, remove the files you modified from pyproject.toml.
Lines 435 to 438 in 179258f
# TODO: Fix B905 (zip-without-explicit-strict) - Remove files below as they're fixed | |
# For contributors working on this issue: | |
# After adding strict={True,False} to zip() calls in a file, | |
# remove its line from this section |
clean_dtypes = self._clean_mapping(self.dtype) | ||
|
||
if self.index_names is not None: | ||
names: Iterable = self.index_names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names: Iterable = self.index_names | |
names: Iterable = self.index_names | |
strict = True |
if self.index_names is not None: | ||
names: Iterable = self.index_names | ||
else: | ||
names = itertools.cycle([None]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names = itertools.cycle([None]) | |
names = itertools.cycle([None]) | |
strict = False |
pandas/io/parsers/base_parser.py
Outdated
else: | ||
names = itertools.cycle([None]) | ||
for i, (arr, name) in enumerate(zip(index, names)): | ||
for i, (arr, name) in enumerate(zip(index, names, strict=True)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i, (arr, name) in enumerate(zip(index, names, strict=True)): | |
for i, (arr, name) in enumerate(zip(index, names, strict=strict)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alvaro-Kothe I made the changes per your request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good overall. Just need to know why you had to use strict=False
in some places.
] | ||
for i, (x, dtype) in enumerate(zip(fmt_columns, self.frame.dtypes)) | ||
for i, (x, dtype) in enumerate( | ||
zip(fmt_columns, self.frame.dtypes, strict=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this False?
idx_values = list( | ||
zip(*frame.index._format_multi(sparsify=False, include_names=False)) | ||
zip( | ||
*frame.index._format_multi(sparsify=False, include_names=False), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this False?
max(*widths) | ||
for widths in zip(self.header_column_widths, body_column_widths) | ||
for widths in zip( | ||
self.header_column_widths, body_column_widths, strict=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this False?
self._check_data_length(names, alldata) | ||
|
||
data = {k: v for k, (i, v) in zip(names, data_tups)} | ||
data = {k: v for k, (i, v) in zip(names, data_tups, strict=False)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this one needs to be False, and the one above doesn't?
**{ | ||
nm: ch.text if ch.text else None | ||
for nm, ch in zip(self.names, el.findall("*")) | ||
for nm, ch in zip(self.names, el.findall("*"), strict=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this False?
level_lengths, | ||
self.df.index.levels, | ||
self.df.index.codes, | ||
strict=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alvaro-Kothe the tests failed on these calls. Once I changed to False, all tests passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @LirongMa |
Add strict to zip() call for #62434
STY: Enforce Ruff rule B905, zip-without-explicit-strict #62434
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.