Fix some SIM114 per file ignores (#11395)

* updating DIRECTORY.md

* Fix some SIM114 per file ignores

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix review issue

---------

Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Maxim Smolskiy 2024-05-10 22:59:53 +03:00 committed by GitHub
parent 1868c0b637
commit c599f6c910
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 6 additions and 12 deletions

View File

@ -39,9 +39,7 @@ def split(root: Node | None, value: int) -> tuple[Node | None, Node | None]:
Left tree contains all values less than split value.
Right tree contains all values greater or equal, than split value
"""
if root is None: # None tree is split into 2 Nones
return None, None
elif root.value is None:
if root is None or root.value is None: # None tree is split into 2 Nones
return None, None
elif value < root.value:
"""

View File

@ -38,7 +38,7 @@ class BinaryHeap:
def __swap_down(self, i: int) -> None:
"""Swap the element down"""
while self.__size >= 2 * i:
if 2 * i + 1 > self.__size:
if 2 * i + 1 > self.__size: # noqa: SIM114
bigger_child = 2 * i
elif self.__heap[2 * i] > self.__heap[2 * i + 1]:
bigger_child = 2 * i

View File

@ -16,7 +16,7 @@ class Heap:
if start > size // 2 - 1:
return
else:
if 2 * start + 2 >= size:
if 2 * start + 2 >= size: # noqa: SIM114
smallest_child = 2 * start + 1
elif heap[2 * start + 1] < heap[2 * start + 2]:
smallest_child = 2 * start + 1

View File

@ -105,7 +105,7 @@ class DecisionTree:
the predictor
"""
for i in range(len(x)):
if len(x[:i]) < self.min_leaf_size:
if len(x[:i]) < self.min_leaf_size: # noqa: SIM114
continue
elif len(x[i:]) < self.min_leaf_size:
continue

View File

@ -65,7 +65,7 @@ class Matrix:
>>> a.validate_indices((0, 0))
True
"""
if not (isinstance(loc, (list, tuple)) and len(loc) == 2):
if not (isinstance(loc, (list, tuple)) and len(loc) == 2): # noqa: SIM114
return False
elif not (0 <= loc[0] < self.row and 0 <= loc[1] < self.column):
return False

View File

@ -77,14 +77,10 @@ max-complexity = 17 # default: 10
[tool.ruff.lint.per-file-ignores]
"arithmetic_analysis/newton_raphson.py" = ["PGH001"]
"data_structures/binary_tree/binary_search_tree_recursive.py" = ["BLE001"]
"data_structures/binary_tree/treap.py" = ["SIM114"]
"data_structures/hashing/tests/test_hash_map.py" = ["BLE001"]
"data_structures/heap/max_heap.py" = ["SIM114"]
"graphs/minimum_spanning_tree_prims.py" = ["SIM114"]
"hashes/enigma_machine.py" = ["BLE001"]
"machine_learning/decision_tree.py" = ["SIM114"]
"machine_learning/sequential_minimum_optimization.py" = ["SIM115"]
"matrix/sherman_morrison.py" = ["SIM103", "SIM114"]
"matrix/sherman_morrison.py" = ["SIM103"]
"other/l*u_cache.py" = ["RUF012"]
"physics/newtons_second_law_of_motion.py" = ["BLE001"]
"project_euler/problem_099/sol1.py" = ["SIM115"]