11"""asyncssh SSH vendor for Dulwich."""
22import asyncio
3- from typing import List , Optional
3+ from typing import TYPE_CHECKING , List , Optional
44
5- from asyncssh .connection import SSHClientConnection , SSHConnection
6- from asyncssh .process import SSHClientProcess
7- from asyncssh .stream import SSHReader
85from dulwich .client import SSHVendor
96
107from scmrepo .asyn import BaseAsyncObject , sync_wrapper
118
9+ if TYPE_CHECKING :
10+ from asyncssh .connection import SSHClientConnection , SSHConnection
11+ from asyncssh .process import SSHClientProcess
12+ from asyncssh .stream import SSHReader
13+
1214
1315class _StderrWrapper :
1416 def __init__ (
15- self , stderr : SSHReader , loop : asyncio .AbstractEventLoop
17+ self , stderr : " SSHReader" , loop : asyncio .AbstractEventLoop
1618 ) -> None :
1719 self .stderr = stderr
1820 self .loop = loop
@@ -34,10 +36,12 @@ async def _read(self, n: Optional[int] = None) -> bytes:
3436
3537
3638class AsyncSSHWrapper (BaseAsyncObject ):
37- def __init__ (self , conn : SSHConnection , proc : SSHClientProcess , ** kwargs ):
39+ def __init__ (
40+ self , conn : "SSHConnection" , proc : "SSHClientProcess" , ** kwargs
41+ ):
3842 super ().__init__ (** kwargs )
39- self .conn : SSHClientConnection = conn
40- self .proc : SSHClientProcess = proc
43+ self .conn : " SSHClientConnection" = conn
44+ self .proc : " SSHClientProcess" = proc
4145 self .stderr = _StderrWrapper (proc .stderr , self .loop )
4246
4347 def can_read (self ) -> bool :
@@ -142,7 +146,7 @@ async def _run_command(
142146 MSG_USERAUTH_PK_OK
143147 ] = _process_public_key_ok_gh
144148
145- conn : SSHClientConnection = await asyncssh .connect (
149+ conn : " SSHClientConnection" = await asyncssh .connect (
146150 host ,
147151 port = port if port is not None else (),
148152 username = username if username is not None else (),
@@ -152,7 +156,7 @@ async def _run_command(
152156 known_hosts = None ,
153157 encoding = None ,
154158 )
155- proc : SSHClientProcess = await conn .create_process (
159+ proc : " SSHClientProcess" = await conn .create_process (
156160 command , encoding = None
157161 )
158162 return AsyncSSHWrapper (conn , proc )
0 commit comments