Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncssh: loosen upper version limit #44

Merged
merged 2 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions scmrepo/git/backend/dulwich/asyncssh_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from scmrepo.asyn import BaseAsyncObject, sync_wrapper

if TYPE_CHECKING:
from asyncssh.connection import SSHClientConnection, SSHConnection
from asyncssh.connection import SSHClientConnection
from asyncssh.process import SSHClientProcess
from asyncssh.stream import SSHReader

Expand Down Expand Up @@ -37,7 +37,7 @@ async def _read(self, n: Optional[int] = None) -> bytes:

class AsyncSSHWrapper(BaseAsyncObject):
def __init__(
self, conn: "SSHConnection", proc: "SSHClientProcess", **kwargs
self, conn: "SSHClientConnection", proc: "SSHClientProcess", **kwargs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were using incorrect type-hints. :)

):
super().__init__(**kwargs)
self.conn: "SSHClientConnection" = conn
Expand Down Expand Up @@ -146,7 +146,7 @@ async def _run_command(
MSG_USERAUTH_PK_OK
] = _process_public_key_ok_gh

conn: "SSHClientConnection" = await asyncssh.connect(
conn = await asyncssh.connect(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer required, since asyncssh is now typed. :)

host,
port=port if port is not None else (),
username=username if username is not None else (),
Expand All @@ -156,9 +156,7 @@ async def _run_command(
known_hosts=None,
encoding=None,
)
proc: "SSHClientProcess" = await conn.create_process(
command, encoding=None
)
proc = await conn.create_process(command, encoding=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer required, since asyncssh is now typed. :)

return AsyncSSHWrapper(conn, proc)

run_command = sync_wrapper(_run_command)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install_requires=
pygtrie>=2.3.2
fsspec>=2021.7.0
pathspec>=0.9.0,<0.10.0
asyncssh>=2.7.1,<2.9
asyncssh>=2.7.1,<3
funcy>=1.14

[options.extras_require]
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ def check() -> bool:
@pytest.fixture
async def ssh_connection(
ssh_conn_info: Dict[str, Any],
) -> AsyncIterator[asyncssh.connection.SSHConnection]:
) -> AsyncIterator[asyncssh.connection.SSHClientConnection]:
async with asyncssh.connect(**ssh_conn_info) as conn:
yield conn


@pytest.fixture
async def sftp(
ssh_connection: asyncssh.connection.SSHConnection,
ssh_connection: asyncssh.connection.SSHClientConnection,
) -> AsyncIterator[asyncssh.SFTPClient]:
async with ssh_connection.start_sftp_client() as sftp:
yield sftp
6 changes: 3 additions & 3 deletions tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from asyncssh import SFTPClient
from asyncssh.connection import SSHConnection
from asyncssh.connection import SSHClientConnection
from git import Repo as GitPythonRepo
from pytest_test_utils import TempDirFactory, TmpDir
from pytest_test_utils.matchers import Matcher
Expand Down Expand Up @@ -844,7 +844,7 @@ async def test_git_ssh(
scm: Git,
git: Git,
sftp: SFTPClient,
ssh_connection: SSHConnection,
ssh_connection: SSHClientConnection,
ssh_conn_info: Dict[str, Any],
):
host, port = ssh_conn_info["host"], ssh_conn_info["port"]
Expand All @@ -868,7 +868,7 @@ async def test_git_ssh(
)

async with sftp.open("test-repo.git/refs/heads/master") as fobj:
assert (await fobj.read()).strip() == rev
assert (await fobj.read(-1, 0)).strip() == rev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SFTPFileProtocol.read requires read and offset to be passed explicitly. This is most likely a bug in typings in asyncssh, but this does not hurt us that much, so just fixing it here.


shutil.rmtree(tmp_dir / ".git")
(tmp_dir / "foo").unlink()
Expand Down