6
6
"""
7
7
import logging
8
8
import os
9
+ import typing as t
9
10
10
11
from . import exc , formats
11
12
from .common import (
17
18
)
18
19
from .session import Session
19
20
21
+ SessionDict = t .Dict [str , t .Any ]
22
+ WindowDict = t .Dict [str , t .Any ]
23
+ PaneDict = t .Dict [str , t .Any ]
24
+
20
25
logger = logging .getLogger (__name__ )
21
26
22
27
@@ -125,7 +130,7 @@ def cmd(self, *args, **kwargs):
125
130
126
131
return tmux_cmd (* args , ** kwargs )
127
132
128
- def _list_sessions (self ):
133
+ def _list_sessions (self ) -> t . List [ SessionDict ] :
129
134
"""
130
135
Return list of sessions in :py:obj:`dict` form.
131
136
@@ -165,12 +170,12 @@ def _list_sessions(self):
165
170
return sessions
166
171
167
172
@property
168
- def _sessions (self ):
173
+ def _sessions (self ) -> t . List [ SessionDict ] :
169
174
"""Property / alias to return :meth:`~._list_sessions`."""
170
175
171
176
return self ._list_sessions ()
172
177
173
- def list_sessions (self ):
178
+ def list_sessions (self ) -> t . List [ Session ] :
174
179
"""
175
180
Return list of :class:`Session` from the ``tmux(1)`` session.
176
181
@@ -181,14 +186,14 @@ def list_sessions(self):
181
186
return [Session (server = self , ** s ) for s in self ._sessions ]
182
187
183
188
@property
184
- def sessions (self ):
189
+ def sessions (self ) -> t . List [ Session ] :
185
190
"""Property / alias to return :meth:`~.list_sessions`."""
186
191
return self .list_sessions ()
187
192
188
193
#: Alias :attr:`sessions` for :class:`~libtmux.common.TmuxRelationalObject`
189
194
children = sessions
190
195
191
- def _list_windows (self ):
196
+ def _list_windows (self ) -> t . List [ WindowDict ] :
192
197
"""
193
198
Return list of windows in :py:obj:`dict` form.
194
199
@@ -239,7 +244,7 @@ def _list_windows(self):
239
244
240
245
return self ._windows
241
246
242
- def _update_windows (self ):
247
+ def _update_windows (self ) -> "Server" :
243
248
"""
244
249
Update internal window data and return ``self`` for chainability.
245
250
@@ -250,7 +255,7 @@ def _update_windows(self):
250
255
self ._list_windows ()
251
256
return self
252
257
253
- def _list_panes (self ):
258
+ def _list_panes (self ) -> t . List [ PaneDict ] :
254
259
"""
255
260
Return list of panes in :py:obj:`dict` form.
256
261
@@ -310,7 +315,7 @@ def _list_panes(self):
310
315
311
316
return self ._panes
312
317
313
- def _update_panes (self ):
318
+ def _update_panes (self ) -> "Server" :
314
319
"""
315
320
Update internal pane data and return ``self`` for chainability.
316
321
@@ -322,7 +327,7 @@ def _update_panes(self):
322
327
return self
323
328
324
329
@property
325
- def attached_sessions (self ):
330
+ def attached_sessions (self ) -> t . Optional [ t . List [ Session ]] :
326
331
"""
327
332
Return active :class:`Session` objects.
328
333
@@ -345,7 +350,7 @@ def attached_sessions(self):
345
350
346
351
return [Session (server = self , ** s ) for s in attached_sessions ] or None
347
352
348
- def has_session (self , target_session , exact = True ):
353
+ def has_session (self , target_session : str , exact : bool = True ) -> bool :
349
354
"""
350
355
Return True if session exists. ``$ tmux has-session``.
351
356
@@ -382,7 +387,7 @@ def kill_server(self):
382
387
"""``$ tmux kill-server``."""
383
388
self .cmd ("kill-server" )
384
389
385
- def kill_session (self , target_session = None ):
390
+ def kill_session (self , target_session = None ) -> "Server" :
386
391
"""
387
392
Kill the tmux session with ``$ tmux kill-session``, return ``self``.
388
393
@@ -462,7 +467,7 @@ def new_session(
462
467
window_command = None ,
463
468
* args ,
464
469
** kwargs ,
465
- ):
470
+ ) -> Session :
466
471
"""
467
472
Return :class:`Session` from ``$ tmux new-session``.
468
473
0 commit comments