Skip to content

Commit b4cc8d2

Browse files
committed
Refactor attached_pane and update return type to Optional
1 parent b813923 commit b4cc8d2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

libtmux/window.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def select_window(self) -> "Window":
355355
"""
356356
return self.session.select_window(self.index)
357357

358-
def select_pane(self, target_pane: str) -> Pane:
358+
def select_pane(self, target_pane: str) -> t.Optional[Pane]:
359359
"""
360360
Return selected :class:`Pane` through ``$ tmux select-pane``.
361361
@@ -379,7 +379,7 @@ def select_pane(self, target_pane: str) -> Pane:
379379

380380
return self.attached_pane
381381

382-
def last_pane(self) -> Pane:
382+
def last_pane(self) -> t.Optional[Pane]:
383383
"""Return last pane."""
384384
return self.select_pane("-l")
385385

@@ -492,7 +492,7 @@ def split_window(
492492
return Pane(window=self, **pane)
493493

494494
@property
495-
def attached_pane(self) -> Pane:
495+
def attached_pane(self) -> t.Optional[Pane]:
496496
"""
497497
Return the attached :class:`Pane`.
498498
@@ -505,10 +505,6 @@ def attached_pane(self) -> Pane:
505505
# for now pane_active is a unicode
506506
if pane.get("pane_active") == "1":
507507
return Pane(window=self, **pane)
508-
else:
509-
continue
510-
511-
return []
512508

513509
def _list_panes(self) -> t.List[PaneDict]:
514510
panes = self.server._update_panes()._panes

0 commit comments

Comments
 (0)