Skip to content

Commit 9dcd906

Browse files
authored
make type imports lazy (#21)
* make type imports lazy * bump to 0.0.6
1 parent e2076b0 commit 9dcd906

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

scmrepo/git/backend/dulwich/asyncssh_vendor.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
"""asyncssh SSH vendor for Dulwich."""
22
import 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
85
from dulwich.client import SSHVendor
96

107
from 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

1315
class _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

3638
class 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)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
description = SCM wrapper and fsspec filesystem for Git for use in DVC
33
name = scmrepo
4-
version = 0.0.5
4+
version = 0.0.6
55
long_description = file: README.md
66
long_description_content_type = text/markdown
77
license = Apache License 2.0

0 commit comments

Comments
 (0)