asyncssh
asyncssh copied to clipboard
Typing error in SSHServerProcessFactory
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?
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!
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.
This fix is now available in AsyncSSH 2.13.0.