Rule proposal: require explicit `strict=` argument for `itertools.batched`
[As of Python 3.13](https://docs.python.org/3/library/itertools.html#itertools.batched), `itertools.batched` has a `strict` parameter that defaults to `False`. By default, the batches might not be of the same size, which may cause subtle bugs. When`strict=True`, it raises `ValueError` if the final batch is not the same size as the rest.
This seems analogous to the existing rule `B905` which requires an explicit `strict=` parameter for `zip`. Hence, I think it makes sense if there is a similar rule for `itertools.batched`.
I volunteer to implement the rule, if accepted!
关闭于 2024-12-08 6 条评论