Skip to content

Fix some SIM114 per file ignores #11395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions data_structures/binary_tree/treap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This improves readability.

The other instances do not improve readability.

return None, None
elif value < root.value:
"""
Expand Down
2 changes: 1 addition & 1 deletion data_structures/heap/max_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def insert(self, value: int) -> None:
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
Expand Down
2 changes: 1 addition & 1 deletion graphs/minimum_spanning_tree_prims.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def top_to_bottom(self, heap, start, size, positions):
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
Expand Down
2 changes: 1 addition & 1 deletion machine_learning/decision_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def train(self, x, y):
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
Expand Down
2 changes: 1 addition & 1 deletion matrix/sherman_morrison.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def validate_indices(self, loc: tuple[int, int]) -> bool:
>>> 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
Expand Down
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down