Add typing information, 2/n (#1178)

* Add typing to Docker Stack modules. Clean modules up.

* Add typing to Docker Swarm modules.

* Add typing to unit tests.

* Add more typing.

* Add ignore.txt entries.
This commit is contained in:
Felix Fontein
2025-10-25 01:16:04 +02:00
committed by GitHub
parent 3350283bcc
commit 6ad4bfcd40
84 changed files with 1496 additions and 1161 deletions
@@ -18,33 +18,33 @@ from ansible_collections.community.docker.plugins.module_utils._api.transport.ss
class SSHAdapterTest(unittest.TestCase):
@staticmethod
def test_ssh_hostname_prefix_trim():
def test_ssh_hostname_prefix_trim() -> None:
conn = SSHHTTPAdapter(base_url="ssh://user@hostname:1234", shell_out=True)
assert conn.ssh_host == "user@hostname:1234"
@staticmethod
def test_ssh_parse_url():
def test_ssh_parse_url() -> None:
c = SSHSocket(host="user@hostname:1234")
assert c.host == "hostname"
assert c.port == "1234"
assert c.user == "user"
@staticmethod
def test_ssh_parse_hostname_only():
def test_ssh_parse_hostname_only() -> None:
c = SSHSocket(host="hostname")
assert c.host == "hostname"
assert c.port is None
assert c.user is None
@staticmethod
def test_ssh_parse_user_and_hostname():
def test_ssh_parse_user_and_hostname() -> None:
c = SSHSocket(host="user@hostname")
assert c.host == "hostname"
assert c.port is None
assert c.user == "user"
@staticmethod
def test_ssh_parse_hostname_and_port():
def test_ssh_parse_hostname_and_port() -> None:
c = SSHSocket(host="hostname:22")
assert c.host == "hostname"
assert c.port == "22"
@@ -27,7 +27,7 @@ else:
class SSLAdapterTest(unittest.TestCase):
def test_only_uses_tls(self):
def test_only_uses_tls(self) -> None:
ssl_context = ssladapter.urllib3.util.ssl_.create_urllib3_context()
assert ssl_context.options & OP_NO_SSLv3
@@ -68,19 +68,19 @@ class MatchHostnameTest(unittest.TestCase):
"version": 3,
}
def test_match_ip_address_success(self):
def test_match_ip_address_success(self) -> None:
assert match_hostname(self.cert, "127.0.0.1") is None
def test_match_localhost_success(self):
def test_match_localhost_success(self) -> None:
assert match_hostname(self.cert, "localhost") is None
def test_match_dns_success(self):
def test_match_dns_success(self) -> None:
assert match_hostname(self.cert, "touhou.gensokyo.jp") is None
def test_match_ip_address_failure(self):
def test_match_ip_address_failure(self) -> None:
with pytest.raises(CertificateError):
match_hostname(self.cert, "192.168.0.25")
def test_match_dns_failure(self):
def test_match_dns_failure(self) -> None:
with pytest.raises(CertificateError):
match_hostname(self.cert, "foobar.co.uk")