Skip to content

RUF007 violates naming convention #12397

@dylwil3

Description

@dylwil3

pairwise-over-zipped (RUF007) appears to violate the naming convention, unless I'm misunderstanding either the rule or the convention.

Perhaps zip-over-pairwise or zip-for-pairwise would be more appropriate? Happy to make the change, or have the issue closed if this seems like not a big deal.

Here is the rule to save you a click:

When iterating over successive pairs of elements, prefer itertools.pairwise() over zip().

letters = "ABCD"
zip(letters, letters[1:])  # ("A", "B"), ("B", "C"), ("C", "D")

Use instead:

from itertools import pairwise

letters = "ABCD"
pairwise(letters)  # ("A", "B"), ("B", "C"), ("C", "D")

And here is the relevant part of the naming convention:

Like Clippy, Ruff's rule names should make grammatical and logical sense when read as "allow ${rule}" or "allow ${rule} items",
as in the context of suppression comments.

For example, AssertFalse fits this convention: it flags assert False statements, and so a suppression comment would be framed as "allow assert False".

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions