summaryrefslogtreecommitdiffstats
path: root/contrib/python/Twisted/py3/twisted/conch/client/connect.py
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-06-22 18:50:56 +0300
committerrobot-piglet <[email protected]>2025-06-22 19:04:42 +0300
commitc7cbc6d480c5488ff6e921c709680fd2c1340a10 (patch)
tree10843f44b67c0fb5717ad555556064095f701d8c /contrib/python/Twisted/py3/twisted/conch/client/connect.py
parent26d391cdb94d2ce5efc8d0cc5cea7607dc363c0b (diff)
Intermediate changes
commit_hash:28750b74281710ec1ab5bdc2403c8ab24bdd164b
Diffstat (limited to 'contrib/python/Twisted/py3/twisted/conch/client/connect.py')
-rw-r--r--contrib/python/Twisted/py3/twisted/conch/client/connect.py54
1 files changed, 38 insertions, 16 deletions
diff --git a/contrib/python/Twisted/py3/twisted/conch/client/connect.py b/contrib/python/Twisted/py3/twisted/conch/client/connect.py
index f21f16768bb..1683e7f0704 100644
--- a/contrib/python/Twisted/py3/twisted/conch/client/connect.py
+++ b/contrib/python/Twisted/py3/twisted/conch/client/connect.py
@@ -1,24 +1,46 @@
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
-#
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Callable
+
+from twisted.internet.defer import Deferred
+from twisted.python.failure import Failure
+
+if TYPE_CHECKING:
+ from twisted.conch.client.options import ConchOptions
+ from twisted.conch.ssh.userauth import SSHUserAuthClient
+
from twisted.conch.client import direct
-connectTypes = {"direct": direct.connect}
+connectTypes: dict[
+ str,
+ Callable[[str, int, ConchOptions, direct._VHK, SSHUserAuthClient], Deferred[None]],
+] = {
+ "direct": direct.connect,
+}
-def connect(host, port, options, verifyHostKey, userAuthObject):
+def connect(
+ host: str,
+ port: int,
+ options: ConchOptions,
+ verifyHostKey: direct._VHK,
+ userAuthObject: SSHUserAuthClient,
+) -> Deferred[None]:
useConnects = ["direct"]
- return _ebConnect(
- None, useConnects, host, port, options, verifyHostKey, userAuthObject
- )
-
-
-def _ebConnect(f, useConnects, host, port, options, vhk, uao):
- if not useConnects:
- return f
- connectType = useConnects.pop(0)
- f = connectTypes[connectType]
- d = f(host, port, options, vhk, uao)
- d.addErrback(_ebConnect, useConnects, host, port, options, vhk, uao)
- return d
+
+ def _ebConnect(interimResult: Failure | None, /) -> Deferred[None] | None | Failure:
+ if not useConnects:
+ return interimResult
+ connectType = useConnects.pop(0)
+ f = connectTypes[connectType]
+ d = f(host, port, options, verifyHostKey, userAuthObject)
+ d.addErrback(_ebConnect)
+ return d
+
+ start: Deferred[None] = Deferred()
+ start.callback(None)
+ start.addCallback(_ebConnect)
+ return start