Skip to content

Commit

Permalink
Handle 'None' cell value when trying to sort
Browse files Browse the repository at this point in the history
  • Loading branch information
OCopping committed May 24, 2024
1 parent 732954d commit 073cfbd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/edge_containers_cli/cmds/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,40 @@ def __init__(
)

def __lt__(self, other: Any) -> bool:
# Handle None as values
if self.value is None and other.value is None:
return cast(bool, False)
elif self.value is None and other.value is not None:
return cast(bool, False)
elif self.value is not None and other.value is None:
return cast(bool, True)

if type(other) != SortableText:
return NotImplemented
return cast(bool, self.value < other.value)

def __gt__(self, other: Any) -> bool:
# Handle None as values
if self.value is None and other.value is None:
return cast(bool, False)
elif self.value is None and other.value is not None:
return cast(bool, True)
elif self.value is not None and other.value is None:
return cast(bool, False)

if type(other) != SortableText:
return NotImplemented
return cast(bool, self.value > other.value)

def __eq__(self, other: Any) -> bool:
# Handle None as values
if self.value is None and other.value is None:
return cast(bool, True)
elif self.value is None and other.value is not None:
return cast(bool, False)
elif self.value is not None and other.value is None:
return cast(bool, False)

if type(other) != SortableText:
return NotImplemented
return cast(bool, self.value == other.value)
Expand Down

0 comments on commit 073cfbd

Please sign in to comment.