ansible-test - Clean up type hints and comments.

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

@ -252,10 +252,10 @@ class ModuleUtilFinder(ast.NodeVisitor):
self.module = None self.module = None
if data_context().content.is_ansible: 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. # 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. # 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 = ( path_map = (
('^hacking/build_library/build_ansible/', 'build_ansible/'), ('^hacking/build_library/build_ansible/', 'build_ansible/'),
('^lib/ansible/', 'ansible/'), ('^lib/ansible/', 'ansible/'),

@ -41,7 +41,7 @@ class CompType(enum.Enum):
""" """
MENU_COMPLETION = '%' 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 For help using this feature, see: https://stackoverflow.com/questions/12044574/getting-complete-and-menu-complete-to-work-together
""" """
LIST = '?' LIST = '?'

@ -69,7 +69,7 @@ def complete_network_testcase(prefix: str, parsed_args: argparse.Namespace, **_)
testcases = [] testcases = []
# since testcases are module specific, don't autocomplete if more than one # since testcases are module specific, don't autocomplete if more than one
# module is specidied # module is specified
if len(parsed_args.include) != 1: if len(parsed_args.include) != 1:
return [] return []

@ -242,8 +242,7 @@ def _command_coverage_combine_powershell(args): # type: (CoverageCombineConfig)
if args.all: if args.all:
missing_sources = [source for source, _source_line_count in sources if source not in coverage_data] 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(_default_stub_value(missing_sources))
coverage_data.update(stubs)
if not args.explain: if not args.explain:
if args.export: if args.export:

@ -322,7 +322,7 @@ class CloudProvider(CloudBase):
return static 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.""" """Write the given content to the config file."""
prefix = '%s-' % os.path.splitext(os.path.basename(self.config_static_path))[0] 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.write(to_bytes(content))
config_fd.flush() config_fd.flush()
def _read_config_template(self): # type: () -> t.Text def _read_config_template(self): # type: () -> str
"""Read and return the configuration template.""" """Read and return the configuration template."""
lines = read_text_file(self.config_template_path).splitlines() lines = read_text_file(self.config_template_path).splitlines()
lines = [line for line in lines if not line.startswith('#')] lines = [line for line in lines if not line.startswith('#')]
@ -345,7 +345,7 @@ class CloudProvider(CloudBase):
return config return config
@staticmethod @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.""" """Populate and return the given template with the provided values."""
for key in sorted(values): for key in sorted(values):
value = values[key] value = values[key]

@ -247,7 +247,7 @@ class PluginInfo:
def content_plugins(): def content_plugins():
""" """
Analyze content. 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]] plugins = {} # type: t.Dict[str, t.Dict[str, PluginInfo]]

@ -132,12 +132,13 @@ def get_podman_host_ip(): # type: () -> str
@cache @cache
def get_podman_default_hostname(): # type: () -> str def get_podman_default_hostname(): # type: () -> t.Optional[str]
"""Return the default hostname of the Podman service. """
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: try:
stdout = raw_command(['podman', 'system', 'connection', 'list', '--format=json'], capture=True)[0] stdout = raw_command(['podman', 'system', 'connection', 'list', '--format=json'], capture=True)[0]
except SubprocessError: except SubprocessError:

@ -363,7 +363,7 @@ class WindowsConfig(HostConfig, metaclass=abc.ABCMeta):
@dataclasses.dataclass @dataclasses.dataclass
class WindowsRemoteConfig(RemoteConfig, WindowsConfig): class WindowsRemoteConfig(RemoteConfig, WindowsConfig):
"""Configuration for a remoe Windows host.""" """Configuration for a remote Windows host."""
def get_defaults(self, context): # type: (HostContext) -> WindowsRemoteCompletionConfig def get_defaults(self, context): # type: (HostContext) -> WindowsRemoteCompletionConfig
"""Return the default settings.""" """Return the default settings."""
return filter_completion(windows_completion()).get(self.name) or windows_completion().get(self.platform) 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 @dataclasses.dataclass
class NetworkRemoteConfig(RemoteConfig, NetworkConfig): class NetworkRemoteConfig(RemoteConfig, NetworkConfig):
"""Configuration for a remoe network host.""" """Configuration for a remote network host."""
collection: t.Optional[str] = None collection: t.Optional[str] = None
connection: 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)) 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 the contents of the specified path as text."""
return to_text(read_binary_file(path)) return to_text(read_binary_file(path))

@ -198,7 +198,7 @@ def create_ssh_port_forwards(
): # type: (...) -> SshProcess ): # type: (...) -> SshProcess
""" """
Create SSH port forwards using the provided list of tuples (target_host, target_port). 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( options = dict(
LogLevel='INFO', # info level required to get messages on stderr indicating the ports assigned to each forward 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: class ShellScriptTemplate:
"""A simple substition template for shell scripts.""" """A simple substitution template for shell scripts."""
def __init__(self, template): # type: (t.Text) -> None def __init__(self, template): # type: (str) -> None
self.template = template self.template = template
def substitute(self, **kwargs: t.Union[str, t.List[str]]) -> str: def substitute(self, **kwargs: t.Union[str, t.List[str]]) -> str:

Loading…
Cancel
Save