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

Enable ruff RUF007 rule #11349

Merged
merged 11 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion data_structures/linked_list/skip_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import annotations

from itertools import pairwise
from random import random
from typing import Generic, TypeVar

Expand Down Expand Up @@ -389,7 +390,7 @@ def traverse_keys(node):

def test_iter_always_yields_sorted_values():
def is_sorted(lst):
return all(next_item >= item for item, next_item in zip(lst, lst[1:]))
return all(next_item >= item for item, next_item in pairwise(lst))

skip_list = SkipList()
for i in range(10):
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ lint.ignore = [ # `ruff rule S101` for a description of that rule
"RUF001", # String contains ambiguous {}. Did you mean {}?
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
"RUF003", # Comment contains ambiguous {}. Did you mean {}?
"RUF007", # Prefer itertools.pairwise() over zip() when iterating over successive pairs
"S101", # Use of `assert` detected -- DO NOT FIX
"S113", # Probable use of requests call without timeout -- FIX ME
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
Expand Down
2 changes: 1 addition & 1 deletion sorts/bead_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def bead_sort(sequence: list) -> list:
if any(not isinstance(x, int) or x < 0 for x in sequence):
raise TypeError("Sequence must be list of non-negative integers")
for _ in range(len(sequence)):
for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])):
for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])): # noqa: RUF007
if rod_upper > rod_lower:
sequence[i] -= rod_upper - rod_lower
sequence[i + 1] += rod_upper - rod_lower
Expand Down