Skip to content
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

Add B911: itertools.batched without strict= #502

Merged
merged 1 commit into from
Dec 8, 2024

Conversation

tjkuson
Copy link
Contributor

@tjkuson tjkuson commented Dec 7, 2024

Checks calls to itertools.batched and batch similar to the implementation of B031.

Closes #498

@tjkuson tjkuson force-pushed the itertools-batched-strict branch from 88c8dd6 to f972b14 Compare December 7, 2024 19:41
@tjkuson tjkuson marked this pull request as ready for review December 7, 2024 19:42
Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks for the simple implementation + good tests.

@@ -258,6 +258,10 @@ This is meant to be enabled by developers writing visitors using the ``ast`` mod

**B910**: Use Counter() instead of defaultdict(int) to avoid excessive memory use as the default dict will record missing keys with the default value when accessed.

**B911**: ``itertools.batched()`` without an explicit `strict=` parameter set. ``strict=True`` causes the resulting iterator to raise a ``ValueError`` if the final batch is shorter than ``n``.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, you get the cool Porsche number.

@cooperlees cooperlees merged commit 994f3dd into PyCQA:main Dec 8, 2024
7 checks passed
@tjkuson tjkuson deleted the itertools-batched-strict branch December 8, 2024 15:07
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.

Rule proposal: require explicit strict= argument for itertools.batched
2 participants