ansible-test - Clean up type hints and comments.

pull/72856/head
Matt Clay 2 years ago
parent 05fc96c927
commit 2f0530396b

@ -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/'),

@ -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 = '?'

@ -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 []

@ -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:

@ -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]

@ -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]]

@ -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:

@ -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

@ -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))

@ -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

@ -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:

Loading…
Cancel
Save