mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
Enable ruff RUF007 rule (#11349)
* Enable ruff RUF005 rule * Enable ruff RUF007 rule * Fix * Fix * Fix * Update sorts/bead_sort.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update sorts/bead_sort.py * Revert "Update sorts/bead_sort.py" This reverts commitb10e5632e4
. * Revert "Update sorts/bead_sort.py" This reverts commit2c1816bf10
. * Update sorts/bead_sort.py --------- Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
parent
42593489d9
commit
7b88e15b1c
|
@ -5,6 +5,7 @@ https://epaperpress.com/sortsearch/download/skiplist.pdf
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from itertools import pairwise
|
||||||
from random import random
|
from random import random
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
|
@ -389,7 +390,7 @@ def test_delete_doesnt_leave_dead_nodes():
|
||||||
|
|
||||||
def test_iter_always_yields_sorted_values():
|
def test_iter_always_yields_sorted_values():
|
||||||
def is_sorted(lst):
|
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()
|
skip_list = SkipList()
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
|
|
@ -13,7 +13,6 @@ lint.ignore = [ # `ruff rule S101` for a description of that rule
|
||||||
"RUF001", # String contains ambiguous {}. Did you mean {}?
|
"RUF001", # String contains ambiguous {}. Did you mean {}?
|
||||||
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
|
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
|
||||||
"RUF003", # Comment 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
|
"S101", # Use of `assert` detected -- DO NOT FIX
|
||||||
"S113", # Probable use of requests call without timeout -- FIX ME
|
"S113", # Probable use of requests call without timeout -- FIX ME
|
||||||
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
|
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
|
||||||
|
|
|
@ -31,7 +31,7 @@ def bead_sort(sequence: list) -> list:
|
||||||
if any(not isinstance(x, int) or x < 0 for x in sequence):
|
if any(not isinstance(x, int) or x < 0 for x in sequence):
|
||||||
raise TypeError("Sequence must be list of non-negative integers")
|
raise TypeError("Sequence must be list of non-negative integers")
|
||||||
for _ in range(len(sequence)):
|
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:
|
if rod_upper > rod_lower:
|
||||||
sequence[i] -= rod_upper - rod_lower
|
sequence[i] -= rod_upper - rod_lower
|
||||||
sequence[i + 1] += rod_upper - rod_lower
|
sequence[i + 1] += rod_upper - rod_lower
|
||||||
|
|
Loading…
Reference in New Issue
Block a user