[flake8-bugbear] itertools.batched() without explicit strict (B911) (#14408)

## Summary

Resolves #14387.

## Test Plan

`cargo nextest run` and `cargo insta test`.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
InSync 2024-12-10 15:39:46 +07:00 committed by GitHub
parent e3f34b8f5b
commit 4b8c815b27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 331 additions and 3 deletions

View file

@ -0,0 +1,59 @@
from itertools import batched, count, cycle, repeat
# Errors
batched(range(3), 1)
batched("abc", 2)
batched([i for i in range(42)], some_n)
batched((foo for foo in cycle()))
batched(itertools.batched([1, 2, 3], strict=True))
# Errors (limited iterators).
batched(repeat(1, 1))
batched(repeat(1, times=4))
# No fix
batched([], **kwargs)
# No errors
batched()
batched(range(3), 0, strict=True)
batched(["a", "b"], count, strict=False)
batched(("a", "b", "c"), zip(repeat()), strict=True)
# No errors (infinite iterators)
batched(cycle("ABCDEF"), 3)
batched(count(), qux + lorem)
batched(repeat(1), ipsum // 19 @ 0x1)
batched(repeat(1, None))
batched(repeat(1, times=None))
import itertools
# Errors
itertools.batched(range(3), 1)
itertools.batched("abc", 2)
itertools.batched([i for i in range(42)], some_n)
itertools.batched((foo for foo in cycle()))
itertools.batched(itertools.batched([1, 2, 3], strict=True))
# Errors (limited iterators).
itertools.batched(repeat(1, 1))
itertools.batched(repeat(1, times=4))
# No fix
itertools.batched([], **kwargs)
# No errors
itertools.batched()
itertools.batched(range(3), 0, strict=True)
itertools.batched(["a", "b"], count, strict=False)
itertools.batched(("a", "b", "c"), zip(repeat()), strict=True)
# No errors (infinite iterators)
itertools.batched(cycle("ABCDEF"), 3)
itertools.batched(count(), qux + lorem)
itertools.batched(repeat(1), ipsum // 19 @ 0x1)
itertools.batched(repeat(1, None))
itertools.batched(repeat(1, times=None))