1212from  prompt_toolkit .input  import  create_pipe_input 
1313from  prompt_toolkit .output .vt100  import  Vt100_Output 
1414
15- __all__  =  [
16-  "PromptToolkitSession" ,
17-  "PromptToolkitSSHServer" ,
18- ]
15+ __all__  =  ["PromptToolkitSSHSession" , "PromptToolkitSSHServer" ]
1916
2017
21- class  PromptToolkitSession (asyncssh .SSHServerSession ):
22-  def  __init__ (self , interact : Callable [[], Awaitable [None ]]) ->  None :
18+ class  PromptToolkitSSHSession (asyncssh .SSHServerSession ):
19+  def  __init__ (
20+  self , interact : Callable [["PromptToolkitSSHSession" ], Awaitable [None ]]
21+  ) ->  None :
2322 self .interact  =  interact 
2423 self ._chan  =  None 
2524 self .app_session : Optional [AppSession ] =  None 
@@ -77,7 +76,7 @@ async def _interact(self) -> None:
7776 with  create_app_session (input = self ._input , output = self ._output ) as  session :
7877 self .app_session  =  session 
7978 try :
80-  await  self .interact ()
79+  await  self .interact (self )
8180 except  BaseException :
8281 traceback .print_exc ()
8382 finally :
@@ -106,7 +105,7 @@ class PromptToolkitSSHServer(asyncssh.SSHServer):
106105
107106 .. code:: python 
108107
109-  async def interact() -> None: 
108+  async def interact(ssh_session: PromptToolkitSSHSession ) -> None: 
110109 await yes_no_dialog("my title", "my text").run_async() 
111110
112111 prompt_session = PromptSession() 
@@ -126,12 +125,14 @@ async def interact() -> None:
126125 loop.run_forever() 
127126 """ 
128127
129-  def  __init__ (self , interact : Callable [[], Awaitable [None ]]) ->  None :
128+  def  __init__ (
129+  self , interact : Callable [[PromptToolkitSSHSession ], Awaitable [None ]]
130+  ) ->  None :
130131 self .interact  =  interact 
131132
132133 def  begin_auth (self , username ):
133134 # No authentication. 
134135 return  False 
135136
136-  def  session_requested (self ) ->  PromptToolkitSession :
137-  return  PromptToolkitSession (self .interact )
137+  def  session_requested (self ) ->  PromptToolkitSSHSession :
138+  return  PromptToolkitSSHSession (self .interact )
0 commit comments