Skip to content

Commit

Permalink
Update for mypy 1.0.0
Browse files Browse the repository at this point in the history
This commit fixes a new issue reported by mypy 1.0.0 and works around
a problem with type variables that was triggering a mypy internal error.
  • Loading branch information
ronf committed Feb 18, 2023
1 parent 67d8c57 commit 0d49161
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions asyncssh/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@
_ProtocolFactory = Union[_ClientFactory, _ServerFactory]

_Conn = TypeVar('_Conn', 'SSHClientConnection', 'SSHServerConnection')
_ConnectionFactory = Callable[[], _Conn]

class _TunnelProtocol(Protocol):
"""Base protocol for connections to tunnel SSH over"""
Expand Down Expand Up @@ -269,7 +268,7 @@ async def create_server(self, session_factory: TCPListenerFactory,

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):
Expand Down Expand Up @@ -376,7 +375,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
Expand Down Expand Up @@ -455,7 +454,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"""

Expand Down Expand Up @@ -4240,9 +4239,10 @@ async def open_connection(self, *args: object, **kwargs: object) -> \

@async_context_manager
async def create_server(
self, session_factory: TCPListenerFactory, listen_host: str,
listen_port: int, *, encoding: Optional[str] = None,
errors: str = 'strict', window: int = _DEFAULT_WINDOW,
self, session_factory: TCPListenerFactory[AnyStr],
listen_host: str, listen_port: int, *,
encoding: Optional[str] = None, errors: str = 'strict',
window: int = _DEFAULT_WINDOW,
max_pktsize: int = _DEFAULT_MAX_PKTSIZE) -> SSHListener:
"""Create a remote SSH TCP listener
Expand Down

0 comments on commit 0d49161

Please sign in to comment.