Skip to content
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

fix(pane,session,server): Return False if type mismatched #510

Merged
merged 2 commits into from
Nov 25, 2023
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
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