From 2f0530396b0bdb025c94b354cde95604ff1fd349 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 8 Jun 2022 20:49:44 -0700 Subject: [PATCH] ansible-test - Clean up type hints and comments. --- test/lib/ansible_test/_internal/classification/python.py | 4 ++-- .../_internal/cli/argparsing/argcompletion.py | 2 +- .../_internal/cli/commands/integration/network.py | 2 +- .../ansible_test/_internal/commands/coverage/combine.py | 3 +-- .../_internal/commands/integration/cloud/__init__.py | 6 +++--- test/lib/ansible_test/_internal/data.py | 2 +- test/lib/ansible_test/_internal/docker_util.py | 9 +++++---- test/lib/ansible_test/_internal/host_configs.py | 4 ++-- test/lib/ansible_test/_internal/io.py | 2 +- test/lib/ansible_test/_internal/ssh.py | 2 +- test/lib/ansible_test/_internal/util_common.py | 4 ++-- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/test/lib/ansible_test/_internal/classification/python.py b/test/lib/ansible_test/_internal/classification/python.py index 6141bb80fcf..3dd572e519f 100644 --- a/test/lib/ansible_test/_internal/classification/python.py +++ b/test/lib/ansible_test/_internal/classification/python.py @@ -252,10 +252,10 @@ class ModuleUtilFinder(ast.NodeVisitor): self.module = None if data_context().content.is_ansible: - # Various parts of the Ansible source tree execute within diffent modules. + # Various parts of the Ansible source tree execute within different modules. # To support import analysis, each file which uses relative imports must reside under a path defined here. # The mapping is a tuple consisting of a path pattern to match and a replacement path. - # During analyis, any relative imports not covered here will result in warnings, which can be fixed by adding the appropriate entry. + # During analysis, any relative imports not covered here will result in warnings, which can be fixed by adding the appropriate entry. path_map = ( ('^hacking/build_library/build_ansible/', 'build_ansible/'), ('^lib/ansible/', 'ansible/'), diff --git a/test/lib/ansible_test/_internal/cli/argparsing/argcompletion.py b/test/lib/ansible_test/_internal/cli/argparsing/argcompletion.py index ca502c530a0..4e90191a596 100644 --- a/test/lib/ansible_test/_internal/cli/argparsing/argcompletion.py +++ b/test/lib/ansible_test/_internal/cli/argparsing/argcompletion.py @@ -41,7 +41,7 @@ class CompType(enum.Enum): """ MENU_COMPLETION = '%' """ - Menu completion, which cyles through each completion instead of showing a list. + Menu completion, which cycles through each completion instead of showing a list. For help using this feature, see: https://stackoverflow.com/questions/12044574/getting-complete-and-menu-complete-to-work-together """ LIST = '?' diff --git a/test/lib/ansible_test/_internal/cli/commands/integration/network.py b/test/lib/ansible_test/_internal/cli/commands/integration/network.py index 86729195b0f..dde4205280f 100644 --- a/test/lib/ansible_test/_internal/cli/commands/integration/network.py +++ b/test/lib/ansible_test/_internal/cli/commands/integration/network.py @@ -69,7 +69,7 @@ def complete_network_testcase(prefix: str, parsed_args: argparse.Namespace, **_) testcases = [] # since testcases are module specific, don't autocomplete if more than one - # module is specidied + # module is specified if len(parsed_args.include) != 1: return [] diff --git a/test/lib/ansible_test/_internal/commands/coverage/combine.py b/test/lib/ansible_test/_internal/commands/coverage/combine.py index ea1851a1c9d..070eef5ce91 100644 --- a/test/lib/ansible_test/_internal/commands/coverage/combine.py +++ b/test/lib/ansible_test/_internal/commands/coverage/combine.py @@ -242,8 +242,7 @@ def _command_coverage_combine_powershell(args): # type: (CoverageCombineConfig) if args.all: missing_sources = [source for source, _source_line_count in sources if source not in coverage_data] - stubs = _default_stub_value(missing_sources) - coverage_data.update(stubs) + coverage_data.update(_default_stub_value(missing_sources)) if not args.explain: if args.export: diff --git a/test/lib/ansible_test/_internal/commands/integration/cloud/__init__.py b/test/lib/ansible_test/_internal/commands/integration/cloud/__init__.py index 5afde048b31..013f022d0c0 100644 --- a/test/lib/ansible_test/_internal/commands/integration/cloud/__init__.py +++ b/test/lib/ansible_test/_internal/commands/integration/cloud/__init__.py @@ -322,7 +322,7 @@ class CloudProvider(CloudBase): return static - def _write_config(self, content): # type: (t.Text) -> None + def _write_config(self, content): # type: (str) -> None """Write the given content to the config file.""" prefix = '%s-' % os.path.splitext(os.path.basename(self.config_static_path))[0] @@ -337,7 +337,7 @@ class CloudProvider(CloudBase): config_fd.write(to_bytes(content)) config_fd.flush() - def _read_config_template(self): # type: () -> t.Text + def _read_config_template(self): # type: () -> str """Read and return the configuration template.""" lines = read_text_file(self.config_template_path).splitlines() lines = [line for line in lines if not line.startswith('#')] @@ -345,7 +345,7 @@ class CloudProvider(CloudBase): return config @staticmethod - def _populate_config_template(template, values): # type: (t.Text, t.Dict[str, str]) -> t.Text + def _populate_config_template(template, values): # type: (str, t.Dict[str, str]) -> str """Populate and return the given template with the provided values.""" for key in sorted(values): value = values[key] diff --git a/test/lib/ansible_test/_internal/data.py b/test/lib/ansible_test/_internal/data.py index 42fa5a2ac79..a7e3bc0fec1 100644 --- a/test/lib/ansible_test/_internal/data.py +++ b/test/lib/ansible_test/_internal/data.py @@ -247,7 +247,7 @@ class PluginInfo: def content_plugins(): """ Analyze content. - The primary purpose of this analysis is to facilitiate mapping of integration tests to the plugin(s) they are intended to test. + The primary purpose of this analysis is to facilitate mapping of integration tests to the plugin(s) they are intended to test. """ plugins = {} # type: t.Dict[str, t.Dict[str, PluginInfo]] diff --git a/test/lib/ansible_test/_internal/docker_util.py b/test/lib/ansible_test/_internal/docker_util.py index 0a17bf4c665..f906d394c4a 100644 --- a/test/lib/ansible_test/_internal/docker_util.py +++ b/test/lib/ansible_test/_internal/docker_util.py @@ -132,12 +132,13 @@ def get_podman_host_ip(): # type: () -> str @cache -def get_podman_default_hostname(): # type: () -> str - """Return the default hostname of the Podman service. +def get_podman_default_hostname(): # type: () -> t.Optional[str] + """ + Return the default hostname of the Podman service. - --format was added in podman 3.3.0, this functionality depends on it's availability + --format was added in podman 3.3.0, this functionality depends on its availability """ - hostname = None + hostname: t.Optional[str] = None try: stdout = raw_command(['podman', 'system', 'connection', 'list', '--format=json'], capture=True)[0] except SubprocessError: diff --git a/test/lib/ansible_test/_internal/host_configs.py b/test/lib/ansible_test/_internal/host_configs.py index 11a45064653..0274996eab2 100644 --- a/test/lib/ansible_test/_internal/host_configs.py +++ b/test/lib/ansible_test/_internal/host_configs.py @@ -363,7 +363,7 @@ class WindowsConfig(HostConfig, metaclass=abc.ABCMeta): @dataclasses.dataclass class WindowsRemoteConfig(RemoteConfig, WindowsConfig): - """Configuration for a remoe Windows host.""" + """Configuration for a remote Windows host.""" def get_defaults(self, context): # type: (HostContext) -> WindowsRemoteCompletionConfig """Return the default settings.""" return filter_completion(windows_completion()).get(self.name) or windows_completion().get(self.platform) @@ -381,7 +381,7 @@ class NetworkConfig(HostConfig, metaclass=abc.ABCMeta): @dataclasses.dataclass class NetworkRemoteConfig(RemoteConfig, NetworkConfig): - """Configuration for a remoe network host.""" + """Configuration for a remote network host.""" collection: t.Optional[str] = None connection: t.Optional[str] = None diff --git a/test/lib/ansible_test/_internal/io.py b/test/lib/ansible_test/_internal/io.py index df8c98d4987..e2ef7a50f84 100644 --- a/test/lib/ansible_test/_internal/io.py +++ b/test/lib/ansible_test/_internal/io.py @@ -19,7 +19,7 @@ def read_json_file(path): # type: (str) -> t.Any return json.loads(read_text_file(path)) -def read_text_file(path): # type: (str) -> t.Text +def read_text_file(path): # type: (str) -> str """Return the contents of the specified path as text.""" return to_text(read_binary_file(path)) diff --git a/test/lib/ansible_test/_internal/ssh.py b/test/lib/ansible_test/_internal/ssh.py index 7cee13c4fb0..184e89406f2 100644 --- a/test/lib/ansible_test/_internal/ssh.py +++ b/test/lib/ansible_test/_internal/ssh.py @@ -198,7 +198,7 @@ def create_ssh_port_forwards( ): # type: (...) -> SshProcess """ Create SSH port forwards using the provided list of tuples (target_host, target_port). - Port bindings will be automatically assigned by SSH and must be collected with a subseqent call to collect_port_forwards. + Port bindings will be automatically assigned by SSH and must be collected with a subsequent call to collect_port_forwards. """ options = dict( LogLevel='INFO', # info level required to get messages on stderr indicating the ports assigned to each forward diff --git a/test/lib/ansible_test/_internal/util_common.py b/test/lib/ansible_test/_internal/util_common.py index 86e0d776bb3..12c96fc4f0e 100644 --- a/test/lib/ansible_test/_internal/util_common.py +++ b/test/lib/ansible_test/_internal/util_common.py @@ -61,8 +61,8 @@ CHECK_YAML_VERSIONS = {} # type: t.Dict[str, t.Any] class ShellScriptTemplate: - """A simple substition template for shell scripts.""" - def __init__(self, template): # type: (t.Text) -> None + """A simple substitution template for shell scripts.""" + def __init__(self, template): # type: (str) -> None self.template = template def substitute(self, **kwargs: t.Union[str, t.List[str]]) -> str: