From a86c66d4a63b38a03868af6dbc6780ddfc91e31c Mon Sep 17 00:00:00 2001 From: shouzy <82171453+realshouzy@users.noreply.github.com> Date: Sat, 11 May 2024 16:01:59 +0200 Subject: [PATCH] Make code more lesbar --- nrw/datastructures/_binary_search_tree.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/nrw/datastructures/_binary_search_tree.py b/nrw/datastructures/_binary_search_tree.py index 65c78bc..dabecb4 100644 --- a/nrw/datastructures/_binary_search_tree.py +++ b/nrw/datastructures/_binary_search_tree.py @@ -66,9 +66,7 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}(node={self._node!r})" def __str__(self) -> str: - if self.is_empty: - return "" - return str(self._node) + return str(self._node) if not self.is_empty else "" @property def is_empty(self) -> bool: @@ -178,11 +176,9 @@ def _ancestor_of_small_right(self) -> BinarySearchTree[ComparableContentT]: Nachfolger mehr hat. Es ist also später möglich, in einem Baum im rechten Nachfolger den Vorgänger des linkesten Nachfolgers zu finden. """ - return ( - self - if self._node_of_left_successor._left.is_empty - else self._node._left._ancestor_of_small_right() - ) + if self._node_of_left_successor._left.is_empty: + return self + return self._node._left._ancestor_of_small_right() @property def _node_of_left_successor(self) -> _BSTNode[ComparableContentT] | None: