Skip to content

Commit f5bbea3

Browse files
Enable ruff RUF005 rule (#11344)
1 parent f437f92 commit f5bbea3

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

Diff for: data_structures/binary_tree/binary_search_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def inorder(curr_node: Node | None) -> list[Node]:
336336
"""
337337
node_list = []
338338
if curr_node is not None:
339-
node_list = inorder(curr_node.left) + [curr_node] + inorder(curr_node.right)
339+
node_list = [*inorder(curr_node.left), curr_node, *inorder(curr_node.right)]
340340
return node_list
341341

342342

Diff for: dynamic_programming/subset_generation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def subset_combinations(elements: list[int], n: int) -> list:
4545
for i in range(1, r + 1):
4646
for j in range(i, 0, -1):
4747
for prev_combination in dp[j - 1]:
48-
dp[j].append(tuple(prev_combination) + (elements[i - 1],))
48+
dp[j].append((*prev_combination, elements[i - 1]))
4949

5050
try:
5151
return sorted(dp[n])

Diff for: maths/odd_sieve.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def odd_sieve(num: int) -> list[int]:
3333
0, ceil((num - i_squared) / (i << 1))
3434
)
3535

36-
return [2] + list(compress(range(3, num, 2), sieve))
36+
return [2, *list(compress(range(3, num, 2), sieve))]
3737

3838

3939
if __name__ == "__main__":

Diff for: pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ lint.ignore = [ # `ruff rule S101` for a description of that rule
1212
"PLW2901", # PLW2901: Redefined loop variable -- FIX ME
1313
"PT011", # `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
1414
"PT018", # Assertion should be broken down into multiple parts
15-
"RUF00", # Ambiguous unicode character and other rules
15+
"RUF001", # String contains ambiguous {}. Did you mean {}?
16+
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
17+
"RUF003", # Comment contains ambiguous {}. Did you mean {}?
18+
"RUF007", # Prefer itertools.pairwise() over zip() when iterating over successive pairs
1619
"S101", # Use of `assert` detected -- DO NOT FIX
1720
"S113", # Probable use of requests call without timeout -- FIX ME
1821
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME

0 commit comments

Comments
 (0)