Fixing various lint errors.

This commit is contained in:
Gareth J. Greenaway 2018-12-20 16:19:01 -08:00
parent 6a65bf94bc
commit 45f363b152
No known key found for this signature in database
GPG key ID: 10B62F8A7CAD7A41
71 changed files with 88 additions and 2 deletions

View file

@ -41,5 +41,6 @@ def run(start=None):
suite = loader.discover(start, 'test_*.py', top)
unittest.TextTestRunner(verbosity=2).run(suite)
if __name__ == "__main__":
run()

View file

@ -78,6 +78,7 @@ def test():
minion = salt.daemons.flo.IofloMinion(opts=opts)
minion.start(behaviors=['raet.flo.behaving'])
if __name__ == '__main__':
console.reinit(verbosity=console.Wordage.concise)
test()

View file

@ -2224,6 +2224,7 @@ def runAll():
unittest.TextTestRunner(verbosity=2).run(suite)
if __name__ == '__main__' and __package__ is None:
#console.reinit(verbosity=console.Wordage.concise)

View file

@ -63,6 +63,7 @@ from salt.ext import six
def __virtual__():
return HAS_HYPCHAT
log = logging.getLogger(__name__)
_DEFAULT_API_URL = 'https://api.hipchat.com'

View file

@ -41,6 +41,7 @@ def __virtual__():
if logstash is not None \
else (False, 'python-logstash not installed')
log = logging.getLogger(__name__)

View file

@ -48,6 +48,7 @@ def __virtual__():
else:
return True
log = logging.getLogger(__name__)

View file

@ -164,6 +164,7 @@ def is_mp_logging_configured():
def is_extended_logging_configured():
return __EXTERNAL_LOGGERS_CONFIGURED
# Store a reference to the temporary queue logging handler
LOGGING_NULL_HANDLER = __NullLoggingHandler(logging.WARNING)

View file

@ -64,6 +64,7 @@ def __virtual__():
else:
return (False, 'The capirca module (capirca_acl) cannot be loaded.')
# ------------------------------------------------------------------------------
# module globals
# ------------------------------------------------------------------------------

View file

@ -704,6 +704,7 @@ def rm_job(user,
return comdat['stderr']
return ret
rm = salt.utils.functools.alias_function(rm_job, 'rm')

View file

@ -302,6 +302,7 @@ def TXT(host, nameserver=None):
return [i for i in cmd['stdout'].split('\n')]
# Let lowercase work, since that is the convention for Salt functions
a = A
aaaa = AAAA

View file

@ -199,6 +199,7 @@ def latest_version(*names, **kwargs):
'''
return '' if len(names) == 1 else dict((x, '') for x in names)
# available_version is being deprecated
available_version = salt.utils.functools.alias_function(latest_version, 'available_version')
@ -485,6 +486,7 @@ def remove(name=None, pkgs=None, **kwargs):
return ret
# Support pkg.delete to remove packages to more closely match pkg_delete
delete = salt.utils.functools.alias_function(remove, 'delete')
# No equivalent to purge packages, use remove instead

View file

@ -1372,6 +1372,7 @@ def config_get_regexp(key,
ret.setdefault(param, []).append(value)
return ret
config_get_regex = salt.utils.functools.alias_function(config_get_regexp, 'config_get_regex')

View file

@ -212,6 +212,7 @@ def list_tab(user):
ret['pre'].append(line)
return ret
# For consistency's sake
ls = salt.utils.functools.alias_function(list_tab, 'ls')
@ -317,4 +318,5 @@ def rm_job(user,
return ret
rm = salt.utils.functools.alias_function(rm_job, 'rm')

View file

@ -26,6 +26,7 @@ def long_range(start, end):
yield start
start += 1
_IPSET_FAMILIES = {
'ipv4': 'inet',
'ip4': 'inet',

View file

@ -87,6 +87,7 @@ def __virtual__():
return 'keystone'
return (False, 'keystone execution module cannot be loaded: keystoneclient python library not available.')
__opts__ = {}

View file

@ -2599,6 +2599,7 @@ def destroy(name, stop=False, path=None):
)
return _change_state('lxc-destroy', name, None, path=path)
# Compatibility between LXC and nspawn
remove = salt.utils.functools.alias_function(destroy, 'remove')
@ -2943,6 +2944,7 @@ def set_password(name, users, password, encrypted=True, path=None):
)
return True
set_pass = salt.utils.functools.alias_function(set_password, 'set_pass')
@ -4209,6 +4211,7 @@ def copy_to(name, source, dest, overwrite=False, makedirs=False, path=None):
overwrite=overwrite,
makedirs=makedirs)
cp = salt.utils.functools.alias_function(copy_to, 'cp')

View file

@ -189,6 +189,7 @@ def latest_version(*names, **kwargs):
else:
return versions_dict
# available_version is being deprecated
available_version = salt.utils.functools.alias_function(latest_version, 'available_version')

View file

@ -179,6 +179,7 @@ def latest_version(*names, **kwargs):
return ret
# available_version is being deprecated
available_version = salt.utils.functools.alias_function(latest_version, 'available_version')

View file

@ -238,6 +238,7 @@ def increment(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT):
except ValueError:
raise SaltInvocationError('Delta value must be an integer')
incr = salt.utils.functools.alias_function(increment, 'incr')
@ -269,4 +270,5 @@ def decrement(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT):
except ValueError:
raise SaltInvocationError('Delta value must be an integer')
decr = salt.utils.functools.alias_function(decrement, 'decr')

View file

@ -1035,6 +1035,7 @@ def hw_addr(iface):
'''
return salt.utils.network.hw_addr(iface)
# Alias hwaddr to preserve backward compat
hwaddr = salt.utils.functools.alias_function(hw_addr, 'hwaddr')
@ -1213,6 +1214,7 @@ def ip_addrs6(interface=None, include_loopback=False, cidr=None):
else:
return addrs
ipaddrs6 = salt.utils.functools.alias_function(ip_addrs6, 'ipaddrs6')

View file

@ -882,6 +882,7 @@ def list_running():
pass
return sorted(ret)
# 'machinectl list' shows only running containers, so allow this to work as an
# alias to nspawn.list_running
list_ = salt.utils.functools.alias_function(list_running, 'list_')
@ -1313,6 +1314,7 @@ def copy_to(name, source, dest, overwrite=False, makedirs=False):
overwrite=overwrite,
makedirs=makedirs)
cp = salt.utils.functools.alias_function(copy_to, 'cp')
@ -1478,4 +1480,5 @@ def pull_dkr(url, name, index):
'''
return _pull_image('dkr', url, name, index=index)
pull_docker = salt.utils.functools.alias_function(pull_dkr, 'pull_docker')

View file

@ -106,6 +106,7 @@ def latest_version(*names, **kwargs):
return ret[names[0]]
return ret
# available_version is being deprecated
available_version = salt.utils.functools.alias_function(latest_version, 'available_version')

View file

@ -277,6 +277,7 @@ def items(*args, **kwargs):
return pillar.compile_pillar()
# Allow pillar.data to also be used to return pillar data
data = salt.utils.functools.alias_function(items, 'data')

View file

@ -218,6 +218,7 @@ def version(*names, **kwargs):
for x, y in six.iteritems(ret)
])
# Support pkg.info get version info, since this is the CLI usage
info = salt.utils.functools.alias_function(version, 'info')
@ -1080,6 +1081,7 @@ def remove(name=None,
return ret
# Support pkg.delete to remove packages, since this is the CLI usage
delete = salt.utils.functools.alias_function(remove, 'delete')
# No equivalent to purge packages, use remove instead

View file

@ -240,6 +240,7 @@ def latest_version(*names, **kwargs):
return ret[names[0]]
return ret
# available_version is being deprecated
available_version = salt.utils.functools.alias_function(latest_version, 'available_version')

View file

@ -660,6 +660,7 @@ def sync_output(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blackl
refresh_modules()
return ret
sync_outputters = salt.utils.functools.alias_function(sync_output, 'sync_outputters')

View file

@ -332,6 +332,7 @@ def latest_version(name, **kwargs):
return ret
return ''
# available_version is being deprecated
available_version = salt.utils.functools.alias_function(latest_version, 'available_version')

View file

@ -164,6 +164,7 @@ def latest_version(*names, **kwargs):
return ret[names[0]]
return ret
# available_version is being deprecated
available_version = salt.utils.functools.alias_function(latest_version, 'available_version')

View file

@ -307,5 +307,6 @@ def _register_functions():
__all__.append(mod_name)
globals()[mod_name] = mod_func
if TESTINFRA_PRESENT:
_register_functions()

View file

@ -198,6 +198,7 @@ def __virtual__():
return __virtualname__
__outputter__ = {
'touch': 'txt',
'append': 'txt',

View file

@ -314,6 +314,7 @@ def hw_addr(iface):
'''
return salt.utils.network.hw_addr(iface)
# Alias hwaddr to preserve backward compat
hwaddr = salt.utils.functools.alias_function(hw_addr, 'hwaddr')
@ -359,6 +360,7 @@ def ip_addrs(interface=None, include_loopback=False):
return salt.utils.network.ip_addrs(interface=interface,
include_loopback=include_loopback)
ipaddrs = salt.utils.functools.alias_function(ip_addrs, 'ipaddrs')
@ -377,6 +379,7 @@ def ip_addrs6(interface=None, include_loopback=False):
return salt.utils.network.ip_addrs6(interface=interface,
include_loopback=include_loopback)
ipaddrs6 = salt.utils.functools.alias_function(ip_addrs6, 'ipaddrs6')

View file

@ -72,6 +72,7 @@ def __virtual__():
return __virtualname__
__func_alias__ = {
'time_': 'time'
}

View file

@ -531,6 +531,7 @@ def latest_version(*names, **kwargs):
return ret[names[0]]
return ret
# available_version is being deprecated
available_version = salt.utils.functools.alias_function(latest_version, 'available_version')
@ -962,6 +963,7 @@ def list_upgrades(refresh=True, **kwargs):
return dict([(x.name, x.version) for x in _yum_pkginfo(out['stdout'])])
# Preserve expected CLI usage (yum list updates)
list_updates = salt.utils.functools.alias_function(list_upgrades, 'list_updates')
@ -2240,6 +2242,7 @@ def list_holds(pattern=__HOLD_PATTERN, full=True):
ret.append(match)
return ret
get_locked_packages = salt.utils.functools.alias_function(list_holds, 'get_locked_packages')
@ -2547,6 +2550,7 @@ def group_install(name,
return install(pkgs=pkgs, **kwargs)
groupinstall = salt.utils.functools.alias_function(group_install, 'groupinstall')

View file

@ -51,6 +51,7 @@ def __virtual__():
return False, 'The \'{0}\' module could not be loaded: ' \
'\'requests\' is not installed.'.format(__virtualname__)
ROUTERS = {'MessagingRouter': 'messaging',
'EventsRouter': 'evconsole',
'ProcessRouter': 'process',

View file

@ -469,6 +469,7 @@ def list_upgrades(refresh=True, **kwargs):
return ret
# Provide a list_updates function for those used to using zypper list-updates
list_updates = salt.utils.functools.alias_function(list_upgrades, 'list_updates')

View file

@ -199,6 +199,7 @@ class NetapiClient(object):
wheel = salt.wheel.WheelClient(self.opts)
return wheel.cmd_async(kwargs)
CLIENTS = [
name for name, _
in inspect.getmembers(NetapiClient, predicate=inspect.ismethod if six.PY2 else None)

View file

@ -81,4 +81,5 @@ def get_application(*args):
return wsgi_app
application = get_application()

View file

@ -81,6 +81,7 @@ def __virtual__():
return False
return 'mongo'
# Set up logging
log = logging.getLogger(__name__)

View file

@ -135,6 +135,7 @@ def _get_options(ret):
return _options
#
# Most email readers to not support <style> tag.
# The following dict and a function provide a primitive styler

View file

@ -25,6 +25,7 @@ def pause(jid, state_id=None, duration=None):
minion = salt.minion.MasterMinion(__opts__)
minion.functions['state.pause'](jid, state_id, duration)
set_pause = salt.utils.functools.alias_function(pause, 'set_pause')
@ -35,6 +36,7 @@ def resume(jid, state_id=None):
minion = salt.minion.MasterMinion(__opts__)
minion.functions['state.resume'](jid, state_id)
rm_pause = salt.utils.functools.alias_function(resume, 'rm_pause')
@ -132,6 +134,7 @@ def orchestrate(mods,
ret['retcode'] = 1
return ret
# Aliases for orchestrate runner
orch = salt.utils.functools.alias_function(orchestrate, 'orch')
sls = salt.utils.functools.alias_function(orchestrate, 'sls')
@ -241,6 +244,7 @@ def orchestrate_show_sls(mods,
ret = {minion.opts['id']: running}
return ret
orch_show_sls = salt.utils.functools.alias_function(orchestrate_show_sls, 'orch_show_sls')

View file

@ -121,6 +121,7 @@ class Dumper(BaseDumper): # pylint: disable=W0232
'''Overwrites Dumper as not for pollute legacy Dumper'''
pass
Dumper.add_multi_representer(EncryptedString, EncryptedString.yaml_dumper)
Dumper.add_multi_representer(type(None), Dumper.represent_none)
Dumper.add_multi_representer(str, Dumper.represent_str)

View file

@ -389,6 +389,7 @@ class Dumper(BaseDumper): # pylint: disable=W0232
def represent_odict(self, data):
return self.represent_mapping('tag:yaml.org,2002:map', list(data.items()))
Dumper.add_multi_representer(type(None), Dumper.represent_none)
if six.PY2:
Dumper.add_multi_representer(six.binary_type, Dumper.represent_str)

View file

@ -213,6 +213,7 @@ def wait(name, **kwargs):
'result': True,
'comment': ''}
# Alias module.watch to module.wait
watch = salt.utils.functools.alias_function(wait, 'watch')
@ -552,4 +553,5 @@ def _get_dict_result(node):
break
return ret
mod_watch = salt.utils.functools.alias_function(run, 'mod_watch')

View file

@ -16,4 +16,5 @@ def _no_op(name, **kwargs):
'''
return dict(name=name, result=True, changes={}, comment='')
set = context = _no_op # pylint: disable=C0103

View file

@ -343,4 +343,5 @@ def managed(name,
'old': old if old else ''}
return ret
manage = salt.utils.functools.alias_function(managed, 'manage')

View file

@ -81,6 +81,7 @@ def computer_desc(name):
'\'{0}\''.format(name))
return ret
computer_description = salt.utils.functools.alias_function(computer_desc, 'computer_description')

View file

@ -67,6 +67,7 @@ def __virtual__():
return False
return 'mongo'
# Set up logging
log = logging.getLogger(__name__)

View file

@ -303,5 +303,6 @@ def run(extension=None, name=None, description=None, salt_dir=None, merge=False,
log.info('New module stored in %s', path)
return path
if __name__ == '__main__':
run()

View file

@ -723,5 +723,6 @@ def _main():
for result in finder.find(path):
print(result)
if __name__ == '__main__':
_main()

View file

@ -403,6 +403,7 @@ of a field to null.
def _failing_new(*args, **kwargs):
raise TypeError('Can\'t create another NullSentinel instance')
NullSentinel.__new__ = staticmethod(_failing_new)
del _failing_new

View file

@ -27,6 +27,7 @@ class DuplicateKeyWarning(RuntimeWarning):
Warned when duplicate keys exist
'''
warnings.simplefilter('always', category=DuplicateKeyWarning)

View file

@ -158,5 +158,6 @@ def main(argv=None):
else:
print(count_results(data, counts))
if __name__ == "__main__":
sys.exit(main())

View file

@ -28,6 +28,7 @@ def _random_name(size=6):
for x in range(size)
)
# Create the cloud instance name to be used throughout the tests
INSTANCE_NAME = _random_name()
PROVIDER_NAME = 'dimensiondata'

View file

@ -33,8 +33,6 @@ class EC2Test(ShellCase):
'''
Integration tests for the EC2 cloud provider in Salt-Cloud
'''
def _installer_name(self):
'''
Determine the downloaded installer name by searching the files

View file

@ -28,6 +28,7 @@ def __random_name(size=6):
for x in range(size)
)
# Create the cloud instance name to be used throughout the tests
INSTANCE_NAME = __random_name()

View file

@ -32,6 +32,7 @@ def __random_string(size=6):
for x in range(size)
)
# Create user strings for tests
ADD_USER = __random_string()
DEL_USER = __random_string()

View file

@ -1001,6 +1001,7 @@ def parse():
return options
if __name__ == '__main__':
exit_code = run(parse())
print('Exit Code: {0}'.format(exit_code))

View file

@ -79,5 +79,6 @@ def func_builder(testdir):
)
return func
for testdir in os.listdir(os.path.join(CURRENT_DIR, 'tests')):
setattr(KitchenTestCase, 'test_kitchen_{0}'.format(testdir), func_builder(testdir))

View file

@ -434,6 +434,7 @@ class MasterSwarm(Swarm):
)
print('Master killed')
# pylint: disable=C0103
if __name__ == '__main__':
swarm = Swarm(parse())

View file

@ -442,5 +442,6 @@ def main():
except KeyboardInterrupt:
sys.exit(1)
if __name__ == "__main__":
main()

View file

@ -60,6 +60,7 @@ class DownloadArtifacts(object):
except IOError:
print('Failed to copy: {0}'.format(remote))
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Jenkins Artifact Download Helper')
parser.add_argument(

View file

@ -184,6 +184,7 @@ class RuntimeVars(object):
object.__setattr__(self, name, value)
return
self._vars[name] = value
# <---- Helper Methods -----------------------------------------------------------------------------------------------
# ----- Global Variables -------------------------------------------------------------------------------------------->

View file

@ -55,6 +55,7 @@ def _has_required_boto():
else:
return True
if _has_required_boto():
region = 'us-east-1'
access_key = 'GKTADJGHEIQSXMKKRBJ08H'

View file

@ -57,6 +57,7 @@ def _has_required_boto():
else:
return True
if _has_required_boto():
region = 'us-east-1'
access_key = 'GKTADJGHEIQSXMKKRBJ08H'

View file

@ -181,6 +181,7 @@ class GlusterResults(object):
success_first_ip_from_second_second_time = success_reverse_already_peer[
'ip']
xml_peer_present = """
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>

View file

@ -40,6 +40,7 @@ def _test_hashlib():
else:
return True
SUPPORTED_HASHLIB = _test_hashlib()

View file

@ -44,6 +44,7 @@ class MockNapalmYangModule(object):
models = MockNapalmYangModels()
utils = MockUtils()
TEST_CONFIG = {
'comment': 'Configuration discarded.',
'already_configured': False,

View file

@ -46,6 +46,7 @@ class RequestPutResponseMock(Mock):
def json(self):
return {'_id': 4321}
REQUEST_MOCK = RequestMock()

View file

@ -60,6 +60,7 @@ def _has_required_boto():
else:
return True
if _has_required_boto():
region = 'us-east-1'
access_key = 'GKTADJGHEIQSXMKKRBJ08H'

View file

@ -58,6 +58,7 @@ def _has_required_boto():
else:
return True
if _has_required_boto():
region = 'us-east-1'
access_key = 'GKTADJGHEIQSXMKKRBJ08H'

View file

@ -53,6 +53,7 @@ def _has_required_boto():
else:
return True
if _has_required_boto():
region = 'us-east-1'
access_key = 'GKTADJGHEIQSXMKKRBJ08H'