66"""
77import logging
88import os
9+ import typing as t
910
1011from . import exc , formats
1112from .common import (
1718)
1819from .session import Session
1920
21+ SessionDict = t .Dict [str , t .Any ]
22+ WindowDict = t .Dict [str , t .Any ]
23+ PaneDict = t .Dict [str , t .Any ]
24+
2025logger = logging .getLogger (__name__ )
2126
2227
@@ -125,7 +130,7 @@ def cmd(self, *args, **kwargs):
125130
126131 return tmux_cmd (* args , ** kwargs )
127132
128- def _list_sessions (self ):
133+ def _list_sessions (self ) -> t . List [ SessionDict ] :
129134 """
130135 Return list of sessions in :py:obj:`dict` form.
131136
@@ -165,12 +170,12 @@ def _list_sessions(self):
165170 return sessions
166171
167172 @property
168- def _sessions (self ):
173+ def _sessions (self ) -> t . List [ SessionDict ] :
169174 """Property / alias to return :meth:`~._list_sessions`."""
170175
171176 return self ._list_sessions ()
172177
173- def list_sessions (self ):
178+ def list_sessions (self ) -> t . List [ Session ] :
174179 """
175180 Return list of :class:`Session` from the ``tmux(1)`` session.
176181
@@ -181,14 +186,14 @@ def list_sessions(self):
181186 return [Session (server = self , ** s ) for s in self ._sessions ]
182187
183188 @property
184- def sessions (self ):
189+ def sessions (self ) -> t . List [ Session ] :
185190 """Property / alias to return :meth:`~.list_sessions`."""
186191 return self .list_sessions ()
187192
188193 #: Alias :attr:`sessions` for :class:`~libtmux.common.TmuxRelationalObject`
189194 children = sessions
190195
191- def _list_windows (self ):
196+ def _list_windows (self ) -> t . List [ WindowDict ] :
192197 """
193198 Return list of windows in :py:obj:`dict` form.
194199
@@ -239,7 +244,7 @@ def _list_windows(self):
239244
240245 return self ._windows
241246
242- def _update_windows (self ):
247+ def _update_windows (self ) -> "Server" :
243248 """
244249 Update internal window data and return ``self`` for chainability.
245250
@@ -250,7 +255,7 @@ def _update_windows(self):
250255 self ._list_windows ()
251256 return self
252257
253- def _list_panes (self ):
258+ def _list_panes (self ) -> t . List [ PaneDict ] :
254259 """
255260 Return list of panes in :py:obj:`dict` form.
256261
@@ -310,7 +315,7 @@ def _list_panes(self):
310315
311316 return self ._panes
312317
313- def _update_panes (self ):
318+ def _update_panes (self ) -> "Server" :
314319 """
315320 Update internal pane data and return ``self`` for chainability.
316321
@@ -322,7 +327,7 @@ def _update_panes(self):
322327 return self
323328
324329 @property
325- def attached_sessions (self ):
330+ def attached_sessions (self ) -> t . Optional [ t . List [ Session ]] :
326331 """
327332 Return active :class:`Session` objects.
328333
@@ -345,7 +350,7 @@ def attached_sessions(self):
345350
346351 return [Session (server = self , ** s ) for s in attached_sessions ] or None
347352
348- def has_session (self , target_session , exact = True ):
353+ def has_session (self , target_session : str , exact : bool = True ) -> bool :
349354 """
350355 Return True if session exists. ``$ tmux has-session``.
351356
@@ -382,7 +387,7 @@ def kill_server(self):
382387 """``$ tmux kill-server``."""
383388 self .cmd ("kill-server" )
384389
385- def kill_session (self , target_session = None ):
390+ def kill_session (self , target_session = None ) -> "Server" :
386391 """
387392 Kill the tmux session with ``$ tmux kill-session``, return ``self``.
388393
@@ -462,7 +467,7 @@ def new_session(
462467 window_command = None ,
463468 * args ,
464469 ** kwargs ,
465- ):
470+ ) -> Session :
466471 """
467472 Return :class:`Session` from ``$ tmux new-session``.
468473
0 commit comments