Minor ansible-test code cleanup. (#59052)

* Minor ansible-test code cleanup.
* Fix type annotations.
pull/59054/head
Matt Clay 5 years ago committed by GitHub
parent 945e35ada2
commit d910c971b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,9 +26,11 @@ def main():
# noinspection PyUnresolvedReferences
found = bool(importlib.util.find_spec('coverage'))
else:
# noinspection PyDeprecation
import imp
try:
# noinspection PyDeprecation
imp.find_module('coverage')
found = True
except ImportError:

@ -94,6 +94,9 @@ class HcloudCloudEnvironment(CloudEnvironment):
"""
def get_environment_config(self):
"""
:rtype: CloudEnvironmentConfig
"""
parser = ConfigParser()
parser.read(self.config_path)

@ -142,7 +142,7 @@ def command_sanity(args):
def collect_code_smell_tests():
"""
:rtype: tuple[SanityCodeSmellTest]
:rtype: tuple[SanityFunc]
"""
skip_file = 'test/sanity/code-smell/skip.txt'
skip_tests = read_lines_without_comments(skip_file, remove_blank_lines=True, optional=True)
@ -383,7 +383,7 @@ SANITY_TESTS = (
def sanity_init():
"""Initialize full sanity test list (includes code-smell scripts determined at runtime)."""
import_plugins('sanity')
sanity_plugins = {} # type: t.Dict[str, type]
sanity_plugins = {} # type: t.Dict[str, t.Type[SanityFunc]]
load_plugins(SanityFunc, sanity_plugins)
sanity_tests = tuple([plugin() for plugin in sanity_plugins.values()])
global SANITY_TESTS # pylint: disable=locally-disabled, global-statement

@ -31,7 +31,7 @@ try:
# noinspection PyCompatibility
from configparser import ConfigParser
except ImportError:
# noinspection PyCompatibility
# noinspection PyCompatibility,PyUnresolvedReferences
from ConfigParser import SafeConfigParser as ConfigParser
try:
@ -788,9 +788,11 @@ def load_module(path, name): # type: (str, str) -> None
sys.modules[name] = module
else:
# noinspection PyDeprecation
import imp
with open(path, 'r') as module_file:
# noinspection PyDeprecation
imp.load_module(name, module_file, path, ('.py', 'r', imp.PY_SOURCE))

Loading…
Cancel
Save