asyncssh icon indicating copy to clipboard operation
asyncssh copied to clipboard

Typing error in SSHServerProcessFactory

Open vxgmichel opened this issue 3 years ago • 2 comments

As far as I understand, SSHServerProcessFactory can be an awaitable. I managed to fix a type error in my code base using the following diff:

diff --git a/asyncssh/process.py b/asyncssh/process.py
index c55e7a9..94cf333 100644
--- a/asyncssh/process.py
+++ b/asyncssh/process.py
@@ -62,7 +62,7 @@ ProcessSource = Union[int, str, socket.socket, PurePath, SSHReader[bytes],
 ProcessTarget = Union[int, str, socket.socket, PurePath, SSHWriter[bytes],
                       asyncio.StreamWriter, _File]
 
-SSHServerProcessFactory = Callable[['SSHServerProcess[AnyStr]'], None]
+SSHServerProcessFactory = Callable[['SSHServerProcess[AnyStr]'], MaybeAwait[None]]
 
 
 class _AsyncFileProtocol(Protocol[AnyStr]):

Did I get this right?

vxgmichel avatar Sep 18 '22 10:09 vxgmichel

Yes - that looks right. Both the code and the documentation agree that the process_factory argument can be either a callable or a coroutine, so the MaybeAwait is appropriate there, similar to what was done for SSHSocketSessionFactory and SSHServerSessionFactory.

I'll make this change - thanks for the report!

ronf avatar Sep 18 '22 13:09 ronf

Ok - this is now in the "develop" branch as commit a618ca7. I also made a few minor improvements to the documentation related to some of the callable arguments in connection.py to better reflect their type.

ronf avatar Sep 18 '22 14:09 ronf

This fix is now available in AsyncSSH 2.13.0.

ronf avatar Dec 27 '22 22:12 ronf