Skip to content

Commit e96a8fd

Browse files
committed
refactor!: Simplify __eq__ to be IDs
1 parent 9b6c5d9 commit e96a8fd

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/libtmux/pane.py

+7
Original file line numberDiff line numberDiff line change
@@ -344,5 +344,12 @@ def reset(self) -> "Pane":
344344
self.cmd("send-keys", r"-R \; clear-history")
345345
return self
346346

347+
#
348+
# Dunder
349+
#
350+
def __eq__(self, other: object) -> bool:
351+
assert isinstance(other, Pane)
352+
return self.pane_id == other.pane_id
353+
347354
def __repr__(self) -> str:
348355
return "{}({} {})".format(self.__class__.__name__, self.pane_id, self.window)

src/libtmux/session.py

+7
Original file line numberDiff line numberDiff line change
@@ -551,5 +551,12 @@ def list_windows(self) -> t.List["Window"]:
551551
#: Was used by TmuxRelationalObject (but that's longer used in this class)
552552
children = windows
553553

554+
#
555+
# Dunder
556+
#
557+
def __eq__(self, other: object) -> bool:
558+
assert isinstance(other, Session)
559+
return self.session_id == other.session_id
560+
554561
def __repr__(self) -> str:
555562
return f"{self.__class__.__name__}({self.session_id} {self.session_name})"

src/libtmux/window.py

+7
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,13 @@ def list_panes(self) -> t.List["Pane"]:
550550
#: TmuxRelationalOjbect anymore
551551
children = panes
552552

553+
#
554+
# Dunder
555+
#
556+
def __eq__(self, other: object) -> bool:
557+
assert isinstance(other, Window)
558+
return self.window_id == other.window_id
559+
553560
def __repr__(self) -> str:
554561
return "{}({} {}:{}, {})".format(
555562
self.__class__.__name__,

0 commit comments

Comments
 (0)