7
7
import logging
8
8
import os
9
9
import typing as t
10
+ from typing import Any , Dict , List , Optional , Union
11
+
12
+ from libtmux .common import tmux_cmd
13
+ from libtmux .window import Window
10
14
11
15
from . import exc , formats
12
16
from .common import (
24
28
25
29
if t .TYPE_CHECKING :
26
30
from .pane import Pane
31
+ from .server import Server
27
32
28
33
29
34
class Session (TmuxMappingObject , TmuxRelationalObject , EnvironmentMixin ):
@@ -54,7 +59,7 @@ class Session(TmuxMappingObject, TmuxRelationalObject, EnvironmentMixin):
54
59
#: namespace used :class:`~libtmux.common.TmuxMappingObject`
55
60
formatter_prefix = "session_"
56
61
57
- def __init__ (self , server = None , ** kwargs ):
62
+ def __init__ (self , server : Optional [ "Server" ] = None , ** kwargs ) -> None :
58
63
EnvironmentMixin .__init__ (self )
59
64
self .server = server
60
65
@@ -64,7 +69,7 @@ def __init__(self, server=None, **kwargs):
64
69
self .server ._update_windows ()
65
70
66
71
@property
67
- def _info (self ):
72
+ def _info (self ) -> Dict [ str , str ] :
68
73
69
74
attrs = {"session_id" : str (self ._session_id )}
70
75
@@ -84,7 +89,7 @@ def by(val) -> bool:
84
89
except IndexError as e :
85
90
logger .error (e )
86
91
87
- def cmd (self , * args , ** kwargs ):
92
+ def cmd (self , * args , ** kwargs ) -> tmux_cmd :
88
93
"""
89
94
Return :meth:`server.cmd`.
90
95
@@ -173,11 +178,11 @@ def rename_session(self, new_name: str) -> "Session":
173
178
174
179
def new_window (
175
180
self ,
176
- window_name = None ,
177
- start_directory = None ,
178
- attach = True ,
179
- window_index = "" ,
180
- window_shell = None ,
181
+ window_name : Optional [ str ] = None ,
182
+ start_directory : None = None ,
183
+ attach : bool = True ,
184
+ window_index : str = "" ,
185
+ window_shell : None = None ,
181
186
) -> Window :
182
187
"""
183
188
Return :class:`Window` from ``$ tmux new-window``.
@@ -255,7 +260,7 @@ def new_window(
255
260
256
261
return window
257
262
258
- def kill_window (self , target_window = None ):
263
+ def kill_window (self , target_window : Optional [ str ] = None ) -> None :
259
264
"""Close a tmux window, and all panes inside it, ``$ tmux kill-window``
260
265
261
266
Kill the current window or the window at ``target-window``. removing it
@@ -374,7 +379,9 @@ def attached_pane(self) -> t.Optional["Pane"]:
374
379
375
380
return self .attached_window .attached_pane
376
381
377
- def set_option (self , option , value , _global = False ):
382
+ def set_option (
383
+ self , option : str , value : Union [int , str ], _global : bool = False
384
+ ) -> None :
378
385
"""
379
386
Set option ``$ tmux set-option <option> <value>``.
380
387
@@ -417,7 +424,9 @@ def set_option(self, option, value, _global=False):
417
424
if isinstance (proc .stderr , list ) and len (proc .stderr ):
418
425
handle_option_error (proc .stderr [0 ])
419
426
420
- def show_options (self , option = None , _global = False ):
427
+ def show_options (
428
+ self , option : Optional [str ] = None , _global : bool = False
429
+ ) -> Union [int , Dict [str , str ], Dict [str , Union [str , int ]]]:
421
430
"""
422
431
Return a dict of options for the window.
423
432
@@ -462,7 +471,7 @@ def show_options(self, option=None, _global=False):
462
471
463
472
return session_options
464
473
465
- def show_option (self , option , _global = False ):
474
+ def show_option (self , option : str , _global : bool = False ) -> Optional [ int ] :
466
475
"""Return a list of options for the window.
467
476
468
477
Parameters
0 commit comments