66"""
77import logging
88import os
9+ import typing as t
910
1011from . import exc , formats
1112from .common import (
1213 EnvironmentMixin ,
14+ PaneDict ,
15+ SessionDict ,
1316 TmuxRelationalObject ,
17+ WindowDict ,
1418 has_gte_version ,
1519 session_check_name ,
1620 tmux_cmd ,
@@ -125,7 +129,7 @@ def cmd(self, *args, **kwargs):
125129
126130 return tmux_cmd (* args , ** kwargs )
127131
128- def _list_sessions (self ):
132+ def _list_sessions (self ) -> t . List [ SessionDict ] :
129133 """
130134 Return list of sessions in :py:obj:`dict` form.
131135
@@ -165,12 +169,12 @@ def _list_sessions(self):
165169 return sessions
166170
167171 @property
168- def _sessions (self ):
172+ def _sessions (self ) -> t . List [ SessionDict ] :
169173 """Property / alias to return :meth:`~._list_sessions`."""
170174
171175 return self ._list_sessions ()
172176
173- def list_sessions (self ):
177+ def list_sessions (self ) -> t . List [ Session ] :
174178 """
175179 Return list of :class:`Session` from the ``tmux(1)`` session.
176180
@@ -181,14 +185,14 @@ def list_sessions(self):
181185 return [Session (server = self , ** s ) for s in self ._sessions ]
182186
183187 @property
184- def sessions (self ):
188+ def sessions (self ) -> t . List [ Session ] :
185189 """Property / alias to return :meth:`~.list_sessions`."""
186190 return self .list_sessions ()
187191
188192 #: Alias :attr:`sessions` for :class:`~libtmux.common.TmuxRelationalObject`
189193 children = sessions
190194
191- def _list_windows (self ):
195+ def _list_windows (self ) -> t . List [ WindowDict ] :
192196 """
193197 Return list of windows in :py:obj:`dict` form.
194198
@@ -239,7 +243,7 @@ def _list_windows(self):
239243
240244 return self ._windows
241245
242- def _update_windows (self ):
246+ def _update_windows (self ) -> "Server" :
243247 """
244248 Update internal window data and return ``self`` for chainability.
245249
@@ -250,7 +254,7 @@ def _update_windows(self):
250254 self ._list_windows ()
251255 return self
252256
253- def _list_panes (self ):
257+ def _list_panes (self ) -> t . List [ PaneDict ] :
254258 """
255259 Return list of panes in :py:obj:`dict` form.
256260
@@ -310,7 +314,7 @@ def _list_panes(self):
310314
311315 return self ._panes
312316
313- def _update_panes (self ):
317+ def _update_panes (self ) -> "Server" :
314318 """
315319 Update internal pane data and return ``self`` for chainability.
316320
@@ -322,7 +326,7 @@ def _update_panes(self):
322326 return self
323327
324328 @property
325- def attached_sessions (self ):
329+ def attached_sessions (self ) -> t . Optional [ t . List [ Session ]] :
326330 """
327331 Return active :class:`Session` objects.
328332
@@ -345,7 +349,7 @@ def attached_sessions(self):
345349
346350 return [Session (server = self , ** s ) for s in attached_sessions ] or None
347351
348- def has_session (self , target_session , exact = True ):
352+ def has_session (self , target_session : str , exact : bool = True ) -> bool :
349353 """
350354 Return True if session exists. ``$ tmux has-session``.
351355
@@ -382,7 +386,7 @@ def kill_server(self):
382386 """``$ tmux kill-server``."""
383387 self .cmd ("kill-server" )
384388
385- def kill_session (self , target_session = None ):
389+ def kill_session (self , target_session = None ) -> "Server" :
386390 """
387391 Kill the tmux session with ``$ tmux kill-session``, return ``self``.
388392
@@ -462,7 +466,7 @@ def new_session(
462466 window_command = None ,
463467 * args ,
464468 ** kwargs ,
465- ):
469+ ) -> Session :
466470 """
467471 Return :class:`Session` from ``$ tmux new-session``.
468472
0 commit comments