Skip to content

Commit

Permalink
fix(pane,session,server[__eq__]): Return False if type mismatched (#…
Browse files Browse the repository at this point in the history
…510)

See also: #505
  • Loading branch information
tony authored Nov 25, 2023
2 parents c729584 + 1372f44 commit ac19b4b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
5 changes: 3 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ $ pip install --user --upgrade --pre libtmux

### Improvement

- `Window.__eq__` now returns `False` instead of raising `AssertionError`, thank
you @m1guelperez! (#505)
- `Server.__eq__`, `Session.__eq__`, `Window.__eq__`, `Pane.__eq__` now returns `False` instead of raising `AssertionError` when type mismatches (#505, #510)

Thank you @m1guelperez for `Window.__eq__`! (#505)

## libtmux 0.24.1 (2023-11-23)

Expand Down
5 changes: 3 additions & 2 deletions src/libtmux/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,9 @@ def reset(self) -> "Pane":
# Dunder
#
def __eq__(self, other: object) -> bool:
assert isinstance(other, Pane)
return self.pane_id == other.pane_id
if isinstance(other, Pane):
return self.pane_id == other.pane_id
return False

def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.pane_id} {self.window})"
Expand Down
11 changes: 6 additions & 5 deletions src/libtmux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,12 @@ def panes(self) -> QueryList[Pane]: # type:ignore
# Dunder
#
def __eq__(self, other: object) -> bool:
assert isinstance(other, Server)
return (
self.socket_name == other.socket_name
and self.socket_path == other.socket_path
)
if isinstance(other, Server):
return (
self.socket_name == other.socket_name
and self.socket_path == other.socket_path
)
return False

def __repr__(self) -> str:
if self.socket_name is not None:
Expand Down
5 changes: 3 additions & 2 deletions src/libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,9 @@ def attached_pane(self) -> t.Optional["Pane"]:
# Dunder
#
def __eq__(self, other: object) -> bool:
assert isinstance(other, Session)
return self.session_id == other.session_id
if isinstance(other, Session):
return self.session_id == other.session_id
return False

def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.session_id} {self.session_name})"
Expand Down

0 comments on commit ac19b4b

Please sign in to comment.