Skip to content

Commit ac19b4b

Browse files
authored
fix(pane,session,server[__eq__]): Return False if type mismatched (#510)
See also: #505
2 parents c729584 + 1372f44 commit ac19b4b

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

CHANGES

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ $ pip install --user --upgrade --pre libtmux
1616

1717
### Improvement
1818

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

2223
## libtmux 0.24.1 (2023-11-23)
2324

src/libtmux/pane.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,9 @@ def reset(self) -> "Pane":
378378
# Dunder
379379
#
380380
def __eq__(self, other: object) -> bool:
381-
assert isinstance(other, Pane)
382-
return self.pane_id == other.pane_id
381+
if isinstance(other, Pane):
382+
return self.pane_id == other.pane_id
383+
return False
383384

384385
def __repr__(self) -> str:
385386
return f"{self.__class__.__name__}({self.pane_id} {self.window})"

src/libtmux/server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,12 @@ def panes(self) -> QueryList[Pane]: # type:ignore
560560
# Dunder
561561
#
562562
def __eq__(self, other: object) -> bool:
563-
assert isinstance(other, Server)
564-
return (
565-
self.socket_name == other.socket_name
566-
and self.socket_path == other.socket_path
567-
)
563+
if isinstance(other, Server):
564+
return (
565+
self.socket_name == other.socket_name
566+
and self.socket_path == other.socket_path
567+
)
568+
return False
568569

569570
def __repr__(self) -> str:
570571
if self.socket_name is not None:

src/libtmux/session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,9 @@ def attached_pane(self) -> t.Optional["Pane"]:
559559
# Dunder
560560
#
561561
def __eq__(self, other: object) -> bool:
562-
assert isinstance(other, Session)
563-
return self.session_id == other.session_id
562+
if isinstance(other, Session):
563+
return self.session_id == other.session_id
564+
return False
564565

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

0 commit comments

Comments
 (0)