Skip to content

Commit ce75a04

Browse files
committed
Enable ruff RUF007 rule
1 parent f5ed227 commit ce75a04

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Diff for: 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):

Diff for: pyproject.toml

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

Diff for: sorts/bead_sort.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
https://en.wikipedia.org/wiki/Bead_sort
44
"""
55

6+
from itertools import pairwise
7+
68

79
def bead_sort(sequence: list) -> list:
810
"""
@@ -31,7 +33,7 @@ def bead_sort(sequence: list) -> list:
3133
if any(not isinstance(x, int) or x < 0 for x in sequence):
3234
raise TypeError("Sequence must be list of non-negative integers")
3335
for _ in range(len(sequence)):
34-
for i, (rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])):
36+
for i, (rod_upper, rod_lower) in enumerate(pairwise(sequence)):
3537
if rod_upper > rod_lower:
3638
sequence[i] -= rod_upper - rod_lower
3739
sequence[i + 1] += rod_upper - rod_lower

0 commit comments

Comments
 (0)