Skip to content

Commit

Permalink
Merge pull request #28 from prakashsellathurai/deepsource-fix-dd400b57
Browse files Browse the repository at this point in the history
Refactor unnecessary `else` / `elif` when `if` block has a `raise` statement
  • Loading branch information
prakashsellathurai committed Jul 28, 2021
2 parents ec2fd41 + c79745d commit 86ef8fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions python/heap/treap.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,15 @@ def __getitem__(self, key):
node = self._find_node(key, self.root)[0]
if node is None:
raise KeyError(key)
else:
return node.value
return node.value

def __delitem__(self, key):
"""Delete a key, value pair identified by key from the tree."""
node, parent = self._find_node(key, self.root)

if node is None:
raise KeyError(key)
elif parent is None and not (node.left and node.right):
if parent is None and not (node.left and node.right):
self.root = node.left or node.right
if self.root:
self.root.parent = None
Expand Down
5 changes: 2 additions & 3 deletions python/problems/unpredictable-array.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,15 @@ def __getitem__(self, key):
node = self._find_node(key, self.root)[0]
if node is None:
raise KeyError(key)
else:
return node.value
return node.value

def __delitem__(self, key):
"""Delete a key, value pair identified by key from the tree."""
node, parent = self._find_node(key, self.root)

if node is None:
raise KeyError(key)
elif parent is None and not (node.left and node.right):
if parent is None and not (node.left and node.right):
self.root = node.left or node.right
if self.root:
self.root.parent = None
Expand Down

0 comments on commit 86ef8fc

Please sign in to comment.