-
Notifications
You must be signed in to change notification settings - Fork 152
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
Type checking against asyncssh using mypy 1.0.0 fails. #539
Comments
It looks like not using a diff --git a/asyncssh/connection.py b/asyncssh/connection.py
index 898652b..fc91eb6 100644
--- a/asyncssh/connection.py
+++ b/asyncssh/connection.py
@@ -179,7 +179,7 @@ _ServerFactory = Callable[[], SSHServer]
_ProtocolFactory = Union[_ClientFactory, _ServerFactory]
_Conn = TypeVar('_Conn', 'SSHClientConnection', 'SSHServerConnection')
-_ConnectionFactory = Callable[[], _Conn]
class _TunnelProtocol(Protocol):
"""Base protocol for connections to tunnel SSH over"""
@@ -269,7 +269,7 @@ _DEFAULT_MAX_LINE_LENGTH = 1024 # 1024 characters
async def _open_proxy(
loop: asyncio.AbstractEventLoop, command: Sequence[str],
- conn_factory: _ConnectionFactory[_Conn]) -> _Conn:
+ conn_factory: Callable[[], _Conn]) -> _Conn:
"""Open a tunnel running a proxy command"""
class _ProxyCommandTunnel(asyncio.SubprocessProtocol):
@@ -376,7 +376,7 @@ async def _open_tunnel(tunnel: object, passphrase: Optional[BytesOrStr]) -> \
async def _connect(options: 'SSHConnectionOptions',
loop: asyncio.AbstractEventLoop, flags: int,
sock: Optional[socket.socket],
- conn_factory: _ConnectionFactory[_Conn], msg: str) -> _Conn:
+ conn_factory: Callable[[],_Conn], msg: str) -> _Conn:
"""Make outbound TCP or SSH tunneled connection"""
host = options.host
@@ -455,7 +455,7 @@ async def _listen(options: 'SSHConnectionOptions',
loop: asyncio.AbstractEventLoop, flags: int,
backlog: int, sock: Optional[socket.socket],
reuse_address: bool, reuse_port: bool,
- conn_factory: _ConnectionFactory[_Conn],
+ conn_factory: Callable[[], _Conn],
msg: str) -> 'SSHAcceptor':
"""Make inbound TCP or SSH tunneled listener"""
jonathan@ubuntu ~/git/asyncssh [develop] |
Thanks for the report! It looks like there's a fix for this already proposed at python/mypy#14642, so this change may not be needed in asyncssh, but let me know if you're still running into issues after that. |
Closing this. There is a mypy fix that got merged! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: python/mypy#14631
I'm opening an issue here as well, to discuss it from the asyncssh side.
So, basically:
mypy -c 'import asyncssh'
fails.The code in question which I think is problematic is this:
https://github.com/ronf/asyncssh/blob/develop/asyncssh/connection.py#L181
The text was updated successfully, but these errors were encountered: