6
6
7
7
"""
8
8
import logging
9
+ import typing as t
9
10
10
11
from . import exc
11
12
from .common import TmuxMappingObject , TmuxRelationalObject
12
13
14
+ if t .TYPE_CHECKING :
15
+ from .server import Server
16
+ from .session import Session
17
+ from .window import Window
18
+
19
+
13
20
logger = logging .getLogger (__name__ )
14
21
15
22
@@ -20,7 +27,7 @@ class Pane(TmuxMappingObject, TmuxRelationalObject):
20
27
``Pane`` instances can send commands directly to a pane, or traverse
21
28
between linked tmux objects.
22
29
23
- Parameters
30
+ Attributes
24
31
----------
25
32
window : :class:`Window`
26
33
@@ -42,13 +49,16 @@ class Pane(TmuxMappingObject, TmuxRelationalObject):
42
49
Accessed April 1st, 2018.
43
50
"""
44
51
45
- #: namespace used :class:`~libtmux.common.TmuxMappingObject`
46
52
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 ):
52
62
self .window = window
53
63
self .session = self .window .session
54
64
self .server = self .session .server
@@ -275,7 +285,10 @@ def select_pane(self) -> "Pane":
275
285
-------
276
286
:class:`pane`
277
287
"""
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
279
292
280
293
def __repr__ (self ) -> str :
281
294
return "{}({} {})" .format (
0 commit comments