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 (
12
13
EnvironmentMixin ,
13
14
TmuxMappingObject ,
14
15
TmuxRelationalObject ,
16
+ WindowDict ,
15
17
handle_option_error ,
16
18
has_version ,
17
19
session_check_name ,
@@ -129,7 +131,7 @@ def switch_client(self):
129
131
if proc .stderr :
130
132
raise exc .LibTmuxException (proc .stderr )
131
133
132
- def rename_session (self , new_name ) :
134
+ def rename_session (self , new_name : str ) -> "Session" :
133
135
"""
134
136
Rename session and return new :class:`Session` object.
135
137
@@ -171,7 +173,7 @@ def new_window(
171
173
attach = True ,
172
174
window_index = "" ,
173
175
window_shell = None ,
174
- ):
176
+ ) -> Window :
175
177
"""
176
178
Return :class:`Window` from ``$ tmux new-window``.
177
179
@@ -273,20 +275,18 @@ def kill_window(self, target_window=None):
273
275
274
276
self .server ._update_windows ()
275
277
276
- def _list_windows (self ):
278
+ def _list_windows (self ) -> t . List [ WindowDict ] :
277
279
windows = self .server ._update_windows ()._windows
278
280
279
- windows = [w for w in windows if w ["session_id" ] == self .id ]
280
-
281
- return windows
281
+ return [w for w in windows if w ["session_id" ] == self .id ]
282
282
283
283
@property
284
- def _windows (self ):
284
+ def _windows (self ) -> t . List [ WindowDict ] :
285
285
"""Property / alias to return :meth:`Session._list_windows`."""
286
286
287
287
return self ._list_windows ()
288
288
289
- def list_windows (self ):
289
+ def list_windows (self ) -> t . List [ Window ] :
290
290
"""Return a list of :class:`Window` from the ``tmux(1)`` session.
291
291
292
292
Returns
@@ -298,15 +298,15 @@ def list_windows(self):
298
298
return [Window (session = self , ** window ) for window in windows ]
299
299
300
300
@property
301
- def windows (self ):
301
+ def windows (self ) -> t . List [ Window ] :
302
302
"""Property / alias to return :meth:`Session.list_windows`."""
303
303
return self .list_windows ()
304
304
305
305
#: Alias :attr:`windows` for :class:`~libtmux.common.TmuxRelationalObject`
306
306
children = windows
307
307
308
308
@property
309
- def attached_window (self ):
309
+ def attached_window (self ) -> Window :
310
310
"""
311
311
Return active :class:`Window` object.
312
312
@@ -333,7 +333,7 @@ def attached_window(self):
333
333
if len (self ._windows ) == int (0 ):
334
334
raise exc .LibTmuxException ("No Windows" )
335
335
336
- def select_window (self , target_window ) :
336
+ def select_window (self , target_window : str ) -> Window :
337
337
"""
338
338
Return :class:`Window` selected via ``$ tmux select-window``.
339
339
0 commit comments