77import logging
88import os
99import 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
1014
1115from . import exc , formats
1216from .common import (
2428
2529if t .TYPE_CHECKING :
2630 from .pane import Pane
31+ from .server import Server
2732
2833
2934class Session (TmuxMappingObject , TmuxRelationalObject , EnvironmentMixin ):
@@ -54,7 +59,7 @@ class Session(TmuxMappingObject, TmuxRelationalObject, EnvironmentMixin):
5459 #: namespace used :class:`~libtmux.common.TmuxMappingObject`
5560 formatter_prefix = "session_"
5661
57- def __init__ (self , server = None , ** kwargs ):
62+ def __init__ (self , server : Optional [ "Server" ] = None , ** kwargs ) -> None :
5863 EnvironmentMixin .__init__ (self )
5964 self .server = server
6065
@@ -64,7 +69,7 @@ def __init__(self, server=None, **kwargs):
6469 self .server ._update_windows ()
6570
6671 @property
67- def _info (self ):
72+ def _info (self ) -> Dict [ str , str ] :
6873
6974 attrs = {"session_id" : str (self ._session_id )}
7075
@@ -84,7 +89,7 @@ def by(val) -> bool:
8489 except IndexError as e :
8590 logger .error (e )
8691
87- def cmd (self , * args , ** kwargs ):
92+ def cmd (self , * args , ** kwargs ) -> tmux_cmd :
8893 """
8994 Return :meth:`server.cmd`.
9095
@@ -173,11 +178,11 @@ def rename_session(self, new_name: str) -> "Session":
173178
174179 def new_window (
175180 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 ,
181186 ) -> Window :
182187 """
183188 Return :class:`Window` from ``$ tmux new-window``.
@@ -255,7 +260,7 @@ def new_window(
255260
256261 return window
257262
258- def kill_window (self , target_window = None ):
263+ def kill_window (self , target_window : Optional [ str ] = None ) -> None :
259264 """Close a tmux window, and all panes inside it, ``$ tmux kill-window``
260265
261266 Kill the current window or the window at ``target-window``. removing it
@@ -374,7 +379,9 @@ def attached_pane(self) -> t.Optional["Pane"]:
374379
375380 return self .attached_window .attached_pane
376381
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 :
378385 """
379386 Set option ``$ tmux set-option <option> <value>``.
380387
@@ -417,7 +424,9 @@ def set_option(self, option, value, _global=False):
417424 if isinstance (proc .stderr , list ) and len (proc .stderr ):
418425 handle_option_error (proc .stderr [0 ])
419426
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 ]]]:
421430 """
422431 Return a dict of options for the window.
423432
@@ -462,7 +471,7 @@ def show_options(self, option=None, _global=False):
462471
463472 return session_options
464473
465- def show_option (self , option , _global = False ):
474+ def show_option (self , option : str , _global : bool = False ) -> Optional [ int ] :
466475 """Return a list of options for the window.
467476
468477 Parameters
0 commit comments