Skip to content

Commit 7b88e15

Browse files
Enable ruff RUF007 rule (TheAlgorithms#11349)
* Enable ruff RUF005 rule * Enable ruff RUF007 rule * Fix * Fix * Fix * Update sorts/bead_sort.py Co-authored-by: Christian Clauss <[email protected]> * Update sorts/bead_sort.py * Revert "Update sorts/bead_sort.py" This reverts commit b10e563. * Revert "Update sorts/bead_sort.py" This reverts commit 2c1816b. * Update sorts/bead_sort.py --------- Co-authored-by: Christian Clauss <[email protected]>
1 parent 4259348 commit 7b88e15

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

data_structures/linked_list/skip_list.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import annotations
77

8+
from itertools import pairwise
89
from random import random
910
from typing import Generic, TypeVar
1011

@@ -389,7 +390,7 @@ def traverse_keys(node):
389390

390391
def test_iter_always_yields_sorted_values():
391392
def is_sorted(lst):
392-
return all(next_item >= item for item, next_item in zip(lst, lst[1:]))
393+
return all(next_item >= item for item, next_item in pairwise(lst))
393394

394395
skip_list = SkipList()
395396
for i in range(10):

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ lint.ignore = [ # `ruff rule S101` for a description of that rule
1313
"RUF001", # String contains ambiguous {}. Did you mean {}?
1414
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
1515
"RUF003", # Comment contains ambiguous {}. Did you mean {}?
16-
"RUF007", # Prefer itertools.pairwise() over zip() when iterating over successive pairs
1716
"S101", # Use of `assert` detected -- DO NOT FIX
1817
"S113", # Probable use of requests call without timeout -- FIX ME
1918
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME

sorts/bead_sort.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def bead_sort(sequence: list) -> list:
3131
if any(not isinstance(x, int) or x < 0 for x in sequence):
3232
raise TypeError("Sequence must be list of non-negative integers")
3333
for _ in range(len(sequence)):
34-
for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])):
34+
for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])): # noqa: RUF007
3535
if rod_upper > rod_lower:
3636
sequence[i] -= rod_upper - rod_lower
3737
sequence[i + 1] += rod_upper - rod_lower

0 commit comments

Comments
 (0)