Skip to content

Commit dc2d49c

Browse files
Merge branch 'master' into fix-some-RUF012-per-file-ignores
2 parents eea84ed + c599f6c commit dc2d49c

File tree

7 files changed

+7
-13
lines changed

7 files changed

+7
-13
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: auto-walrus
1717

1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.4.2
19+
rev: v0.4.3
2020
hooks:
2121
- id: ruff
2222
- id: ruff-format

data_structures/binary_tree/treap.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ def split(root: Node | None, value: int) -> tuple[Node | None, Node | None]:
3939
Left tree contains all values less than split value.
4040
Right tree contains all values greater or equal, than split value
4141
"""
42-
if root is None: # None tree is split into 2 Nones
43-
return None, None
44-
elif root.value is None:
42+
if root is None or root.value is None: # None tree is split into 2 Nones
4543
return None, None
4644
elif value < root.value:
4745
"""

data_structures/heap/max_heap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def insert(self, value: int) -> None:
3838
def __swap_down(self, i: int) -> None:
3939
"""Swap the element down"""
4040
while self.__size >= 2 * i:
41-
if 2 * i + 1 > self.__size:
41+
if 2 * i + 1 > self.__size: # noqa: SIM114
4242
bigger_child = 2 * i
4343
elif self.__heap[2 * i] > self.__heap[2 * i + 1]:
4444
bigger_child = 2 * i

graphs/minimum_spanning_tree_prims.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def top_to_bottom(self, heap, start, size, positions):
1616
if start > size // 2 - 1:
1717
return
1818
else:
19-
if 2 * start + 2 >= size:
19+
if 2 * start + 2 >= size: # noqa: SIM114
2020
smallest_child = 2 * start + 1
2121
elif heap[2 * start + 1] < heap[2 * start + 2]:
2222
smallest_child = 2 * start + 1

machine_learning/decision_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def train(self, x, y):
105105
the predictor
106106
"""
107107
for i in range(len(x)):
108-
if len(x[:i]) < self.min_leaf_size:
108+
if len(x[:i]) < self.min_leaf_size: # noqa: SIM114
109109
continue
110110
elif len(x[i:]) < self.min_leaf_size:
111111
continue

matrix/sherman_morrison.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def validate_indices(self, loc: tuple[int, int]) -> bool:
6565
>>> a.validate_indices((0, 0))
6666
True
6767
"""
68-
if not (isinstance(loc, (list, tuple)) and len(loc) == 2):
68+
if not (isinstance(loc, (list, tuple)) and len(loc) == 2): # noqa: SIM114
6969
return False
7070
elif not (0 <= loc[0] < self.row and 0 <= loc[1] < self.column):
7171
return False

pyproject.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,10 @@ max-complexity = 17 # default: 10
7777
[tool.ruff.lint.per-file-ignores]
7878
"arithmetic_analysis/newton_raphson.py" = ["PGH001"]
7979
"data_structures/binary_tree/binary_search_tree_recursive.py" = ["BLE001"]
80-
"data_structures/binary_tree/treap.py" = ["SIM114"]
8180
"data_structures/hashing/tests/test_hash_map.py" = ["BLE001"]
82-
"data_structures/heap/max_heap.py" = ["SIM114"]
83-
"graphs/minimum_spanning_tree_prims.py" = ["SIM114"]
8481
"hashes/enigma_machine.py" = ["BLE001"]
85-
"machine_learning/decision_tree.py" = ["SIM114"]
8682
"machine_learning/sequential_minimum_optimization.py" = ["SIM115"]
87-
"matrix/sherman_morrison.py" = ["SIM103", "SIM114"]
83+
"matrix/sherman_morrison.py" = ["SIM103"]
8884
"physics/newtons_second_law_of_motion.py" = ["BLE001"]
8985
"project_euler/problem_099/sol1.py" = ["SIM115"]
9086
"sorts/external_sort.py" = ["SIM115"]

0 commit comments

Comments
 (0)