Skip to content

Commit 013f1a9

Browse files
committed
chore(Pane): Add window, session, server instance for typings
1 parent 9c58e0f commit 013f1a9

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

libtmux/pane.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66
77
"""
88
import logging
9+
import typing as t
910

1011
from . import exc
1112
from .common import TmuxMappingObject, TmuxRelationalObject
1213

14+
if t.TYPE_CHECKING:
15+
from .server import Server
16+
from .session import Session
17+
from .window import Window
18+
19+
1320
logger = logging.getLogger(__name__)
1421

1522

@@ -20,7 +27,7 @@ class Pane(TmuxMappingObject, TmuxRelationalObject):
2027
``Pane`` instances can send commands directly to a pane, or traverse
2128
between linked tmux objects.
2229
23-
Parameters
30+
Attributes
2431
----------
2532
window : :class:`Window`
2633
@@ -42,13 +49,16 @@ class Pane(TmuxMappingObject, TmuxRelationalObject):
4249
Accessed April 1st, 2018.
4350
"""
4451

45-
#: namespace used :class:`~libtmux.common.TmuxMappingObject`
4652
formatter_prefix = "pane_"
47-
48-
def __init__(self, window=None, **kwargs):
49-
if not window:
50-
raise ValueError("Pane must have ``Window`` object")
51-
53+
"""Namespace used for :class:`~libtmux.common.TmuxMappingObject`"""
54+
window: "Window"
55+
""":class:`libtmux.Window` pane is linked to"""
56+
session: "Session"
57+
""":class:`libtmux.Session` pane is linked to"""
58+
server: "Server"
59+
""":class:`libtmux.Server` pane is linked to"""
60+
61+
def __init__(self, window: "Window", **kwargs):
5262
self.window = window
5363
self.session = self.window.session
5464
self.server = self.session.server
@@ -275,7 +285,10 @@ def select_pane(self) -> "Pane":
275285
-------
276286
:class:`pane`
277287
"""
278-
return self.window.select_pane(self.get("pane_id"))
288+
pane = self.window.select_pane(self._pane_id)
289+
if pane is None:
290+
raise exc.LibTmuxException(f"Pane not found: {self}")
291+
return pane
279292

280293
def __repr__(self) -> str:
281294
return "{}({} {})".format(

0 commit comments

Comments
 (0)