summaryrefslogtreecommitdiff
path: root/test/lib/ansible_test/_internal/containers.py
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2022-08-04 15:51:11 -0700
committerGitHub <noreply@github.com>2022-08-04 15:51:11 -0700
commit5bee66fc5d2514fb2000bb8adffe84de94516964 (patch)
tree9ac339dc51561b993a8179b94b30d4dd1a2ee2b4 /test/lib/ansible_test/_internal/containers.py
parentb993b5cd49662f715774c333ce98e2845227ab66 (diff)
downloadansible-5bee66fc5d2514fb2000bb8adffe84de94516964.tar.gz
ansible-test - More type hint updates. (#78455)
* Simple regex replace of multi-line function arg annotations on the first line. * Manually fix up ArgumentParser type annotations. * Manual type hint conversions. * Manual conversion of function type hints. * Remove unnecessary type hints on for statements.
Diffstat (limited to 'test/lib/ansible_test/_internal/containers.py')
-rw-r--r--test/lib/ansible_test/_internal/containers.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/lib/ansible_test/_internal/containers.py b/test/lib/ansible_test/_internal/containers.py
index 9140ecaee3..bfd01dc1d1 100644
--- a/test/lib/ansible_test/_internal/containers.py
+++ b/test/lib/ansible_test/_internal/containers.py
@@ -243,7 +243,7 @@ def get_container_database(args: EnvironmentConfig) -> ContainerDatabase:
class ContainerAccess:
"""Information needed for one test host to access a single container supporting tests."""
- def __init__(self, host_ip, names, ports, forwards): # type: (str, t.List[str], t.Optional[t.List[int]], t.Optional[t.Dict[int, int]]) -> None
+ def __init__(self, host_ip: str, names: t.List[str], ports: t.Optional[t.List[int]], forwards: t.Optional[t.Dict[int, int]]) -> None:
# if forwards is set
# this is where forwards are sent (it is the host that provides an indirect connection to the containers on alternate ports)
# /etc/hosts uses 127.0.0.1 (since port redirection will be used)
@@ -270,7 +270,7 @@ class ContainerAccess:
return ports
@staticmethod
- def from_dict(data): # type: (t.Dict[str, t.Any]) -> ContainerAccess
+ def from_dict(data: t.Dict[str, t.Any]) -> ContainerAccess:
"""Return a ContainerAccess instance from the given dict."""
forwards = data.get('forwards')
@@ -302,11 +302,11 @@ class ContainerAccess:
class ContainerDatabase:
"""Database of running containers used to support tests."""
- def __init__(self, data): # type: (t.Dict[str, t.Dict[str, t.Dict[str, ContainerAccess]]]) -> None
+ def __init__(self, data: t.Dict[str, t.Dict[str, t.Dict[str, ContainerAccess]]]) -> None:
self.data = data
@staticmethod
- def from_dict(data): # type: (t.Dict[str, t.Any]) -> ContainerDatabase
+ def from_dict(data: t.Dict[str, t.Any]) -> ContainerDatabase:
"""Return a ContainerDatabase instance from the given dict."""
return ContainerDatabase(dict((access_name,
dict((context_name,
@@ -632,7 +632,7 @@ class SupportContainer:
self.published_ports = published_ports
-def wait_for_file(args, # type: EnvironmentConfig
+def wait_for_file(args: EnvironmentConfig,
container_name: str,
path: str,
sleep: int,
@@ -666,7 +666,7 @@ def cleanup_containers(args: EnvironmentConfig) -> None:
display.notice('Remember to run `docker rm -f %s` when finished testing.' % container.name)
-def create_hosts_entries(context): # type: (t.Dict[str, ContainerAccess]) -> t.List[str]
+def create_hosts_entries(context: t.Dict[str, ContainerAccess]) -> t.List[str]:
"""Return hosts entries for the specified context."""
entries = []
unique_id = uuid.uuid4()
@@ -724,7 +724,7 @@ def create_container_hooks(
return pre_target, post_target
-def create_managed_contexts(control_contexts): # type: (t.Dict[str, t.Dict[str, ContainerAccess]]) -> t.Dict[str, t.Dict[str, ContainerAccess]]
+def create_managed_contexts(control_contexts: t.Dict[str, t.Dict[str, ContainerAccess]]) -> t.Dict[str, t.Dict[str, ContainerAccess]]:
"""Create managed contexts from the given control contexts."""
managed_contexts: t.Dict[str, t.Dict[str, ContainerAccess]] = {}