ansible-test - Fix type hints.
This commit is contained in:
2
changelogs/fragments/ansible-test-fix-type-hints.yml
Normal file
2
changelogs/fragments/ansible-test-fix-type-hints.yml
Normal file
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- ansible-test - Fix type hints.
|
||||
@ -60,7 +60,7 @@ def do_network_integration(
|
||||
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.NETWORK_INTEGRATION) # network-integration
|
||||
|
||||
|
||||
def complete_network_testcase(prefix, parsed_args, **_): # type: (str, argparse.Namespace, ...) -> t.List[str]
|
||||
def complete_network_testcase(prefix: str, parsed_args: argparse.Namespace, **_) -> t.List[str]:
|
||||
"""Return a list of test cases matching the given prefix if only one target was parsed from the command line, otherwise return an empty list."""
|
||||
testcases = []
|
||||
|
||||
|
||||
@ -13,14 +13,14 @@ from .argparsing.argcompletion import (
|
||||
)
|
||||
|
||||
|
||||
def complete_target(completer, prefix, parsed_args, **_): # type: (OptionCompletionFinder, str, argparse.Namespace, ...) -> t.List[str]
|
||||
def complete_target(completer: OptionCompletionFinder, prefix: str, parsed_args: argparse.Namespace, **_) -> t.List[str]:
|
||||
"""Perform completion for the targets configured for the command being parsed."""
|
||||
matches = find_target_completion(parsed_args.targets_func, prefix, completer.list_mode)
|
||||
completer.disable_completion_mangling = completer.list_mode and len(matches) > 1
|
||||
return matches
|
||||
|
||||
|
||||
def complete_choices(choices, prefix, **_): # type: (t.List[str], str, ...) -> t.List[str]
|
||||
def complete_choices(choices: t.List[str], prefix: str, **_) -> t.List[str]:
|
||||
"""Perform completion using the provided choices."""
|
||||
matches = [choice for choice in choices if choice.startswith(prefix)]
|
||||
return matches
|
||||
|
||||
@ -526,24 +526,24 @@ def add_environment_remote(
|
||||
)
|
||||
|
||||
|
||||
def complete_remote_stage(prefix, **_): # type: (str, ...) -> t.List[str]
|
||||
def complete_remote_stage(prefix: str, **_) -> t.List[str]:
|
||||
"""Return a list of supported stages matching the given prefix."""
|
||||
return [stage for stage in ('prod', 'dev') if stage.startswith(prefix)]
|
||||
|
||||
|
||||
def complete_windows(prefix, parsed_args, **_): # type: (str, argparse.Namespace, ...) -> t.List[str]
|
||||
def complete_windows(prefix: str, parsed_args: argparse.Namespace, **_) -> t.List[str]:
|
||||
"""Return a list of supported Windows versions matching the given prefix, excluding versions already parsed from the command line."""
|
||||
return [i for i in get_windows_version_choices() if i.startswith(prefix) and (not parsed_args.windows or i not in parsed_args.windows)]
|
||||
|
||||
|
||||
def complete_network_platform(prefix, parsed_args, **_): # type: (str, argparse.Namespace, ...) -> t.List[str]
|
||||
def complete_network_platform(prefix: str, parsed_args: argparse.Namespace, **_) -> t.List[str]:
|
||||
"""Return a list of supported network platforms matching the given prefix, excluding platforms already parsed from the command line."""
|
||||
images = sorted(filter_completion(NETWORK_COMPLETION))
|
||||
|
||||
return [i for i in images if i.startswith(prefix) and (not parsed_args.platform or i not in parsed_args.platform)]
|
||||
|
||||
|
||||
def complete_network_platform_collection(prefix, parsed_args, **_): # type: (str, argparse.Namespace, ...) -> t.List[str]
|
||||
def complete_network_platform_collection(prefix: str, parsed_args: argparse.Namespace, **_) -> t.List[str]:
|
||||
"""Return a list of supported network platforms matching the given prefix, excluding collection platforms already parsed from the command line."""
|
||||
left = prefix.split('=')[0]
|
||||
images = sorted(set(image.platform for image in filter_completion(NETWORK_COMPLETION).values()))
|
||||
@ -551,7 +551,7 @@ def complete_network_platform_collection(prefix, parsed_args, **_): # type: (st
|
||||
return [i + '=' for i in images if i.startswith(left) and (not parsed_args.platform_collection or i not in [x[0] for x in parsed_args.platform_collection])]
|
||||
|
||||
|
||||
def complete_network_platform_connection(prefix, parsed_args, **_): # type: (str, argparse.Namespace, ...) -> t.List[str]
|
||||
def complete_network_platform_connection(prefix: str, parsed_args: argparse.Namespace, **_) -> t.List[str]:
|
||||
"""Return a list of supported network platforms matching the given prefix, excluding connection platforms already parsed from the command line."""
|
||||
left = prefix.split('=')[0]
|
||||
images = sorted(set(image.platform for image in filter_completion(NETWORK_COMPLETION).values()))
|
||||
|
||||
@ -152,7 +152,7 @@ def enumerate_python_arcs(
|
||||
modules, # type: t.Dict[str, str]
|
||||
collection_search_re, # type: t.Optional[t.Pattern]
|
||||
collection_sub_re, # type: t.Optional[t.Pattern]
|
||||
): # type: (...) -> t.Generator[t.Tuple[str, t.Set[t.Tuple[int, int]]]]
|
||||
): # type: (...) -> t.Generator[t.Tuple[str, t.Set[t.Tuple[int, int]]], None, None]
|
||||
"""Enumerate Python code coverage arcs in the given file."""
|
||||
if os.path.getsize(path) == 0:
|
||||
display.warning('Empty coverage file: %s' % path, verbosity=2)
|
||||
@ -193,7 +193,7 @@ def enumerate_powershell_lines(
|
||||
path, # type: str
|
||||
collection_search_re, # type: t.Optional[t.Pattern]
|
||||
collection_sub_re, # type: t.Optional[t.Pattern]
|
||||
): # type: (...) -> t.Generator[t.Tuple[str, t.Dict[int, int]]]
|
||||
): # type: (...) -> t.Generator[t.Tuple[str, t.Dict[int, int]], None, None]
|
||||
"""Enumerate PowerShell code coverage lines in the given file."""
|
||||
if os.path.getsize(path) == 0:
|
||||
display.warning('Empty coverage file: %s' % path, verbosity=2)
|
||||
|
||||
@ -131,7 +131,7 @@ def _generate_powershell_xml(coverage_file): # type: (str) -> Element
|
||||
return elem_coverage
|
||||
|
||||
|
||||
def _add_cobertura_package(packages, package_name, package_data): # type: (SubElement, str, t.Dict[str, t.Dict[str, int]]) -> t.Tuple[int, int]
|
||||
def _add_cobertura_package(packages, package_name, package_data): # type: (Element, str, t.Dict[str, t.Dict[str, int]]) -> t.Tuple[int, int]
|
||||
"""Add a package element to the given packages element."""
|
||||
elem_package = SubElement(packages, 'package')
|
||||
elem_classes = SubElement(elem_package, 'classes')
|
||||
|
||||
@ -103,7 +103,7 @@ def run_support_container(
|
||||
args, # type: EnvironmentConfig
|
||||
context, # type: str
|
||||
image, # type: str
|
||||
name, # type: name
|
||||
name, # type: str
|
||||
ports, # type: t.List[int]
|
||||
aliases=None, # type: t.Optional[t.List[str]]
|
||||
start=True, # type: bool
|
||||
|
||||
@ -254,7 +254,7 @@ def docker_run(
|
||||
raise ApplicationError('Failed to run docker image "%s".' % image)
|
||||
|
||||
|
||||
def docker_start(args, container_id, options=None): # type: (EnvironmentConfig, str, t.Optional[t.List[str]]) -> (t.Optional[str], t.Optional[str])
|
||||
def docker_start(args, container_id, options=None): # type: (EnvironmentConfig, str, t.Optional[t.List[str]]) -> t.Tuple[t.Optional[str], t.Optional[str]]
|
||||
"""
|
||||
Start a docker container by name or ID
|
||||
"""
|
||||
|
||||
@ -16,7 +16,7 @@ def get_path_provider_classes(provider_type): # type: (t.Type[TPathProvider]) -
|
||||
return sorted(get_subclasses(provider_type), key=lambda c: (c.priority, c.__name__))
|
||||
|
||||
|
||||
def find_path_provider(provider_type, # type: t.Type[TPathProvider],
|
||||
def find_path_provider(provider_type, # type: t.Type[TPathProvider]
|
||||
provider_classes, # type: t.List[t.Type[TPathProvider]]
|
||||
path, # type: str
|
||||
walk, # type: bool
|
||||
|
||||
@ -155,7 +155,7 @@ def walk_units_targets(): # type: () -> t.Iterable[TestTarget]
|
||||
return walk_test_targets(path=data_context().content.unit_path, module_path=data_context().content.unit_module_path, extensions=('.py',), prefix='test_')
|
||||
|
||||
|
||||
def walk_compile_targets(include_symlinks=True): # type: (bool) -> t.Iterable[TestTarget, ...]
|
||||
def walk_compile_targets(include_symlinks=True): # type: (bool) -> t.Iterable[TestTarget]
|
||||
"""Return an iterable of compile targets."""
|
||||
return walk_test_targets(module_path=data_context().content.module_path, extensions=('.py',), extra_dirs=('bin',), include_symlinks=include_symlinks)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user