Merge pull request #51631 from Ch3LL/lint-2017

Fix pylint on 2017.7
This commit is contained in:
Daniel Wozniak 2019-02-13 19:50:57 -07:00 committed by GitHub
commit b5ae53a3b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 81 additions and 4 deletions

View file

@ -133,6 +133,7 @@ def string_io(data=None): # cStringIO can't handle unicode
except (UnicodeEncodeError, TypeError):
return StringIO(data)
if PY3:
import ipaddress
else:

View file

@ -95,6 +95,7 @@ def _gather_buffer_space():
# Return the higher number between 5% of the system memory and 10MiB
return max([total_mem * 0.05, 10 << 20])
# For the time being this will be a fixed calculation
# TODO: Allow user configuration
_DFLT_IPC_WBUFFER = _gather_buffer_space() * .5

View file

@ -60,6 +60,7 @@ import salt.ext.six as 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__():
else:
return True
log = logging.getLogger(__name__)

View file

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

View file

@ -84,6 +84,7 @@ import salt.output.highstate
def __virtual__():
return HAS_SLACKCLIENT
log = logging.getLogger(__name__)

View file

@ -163,6 +163,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

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

View file

@ -301,6 +301,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

@ -4379,6 +4379,7 @@ def pause(name):
.format(name))}
return _change_state(name, 'pause', 'paused')
freeze = salt.utils.alias_function(pause, 'freeze')
@ -4586,6 +4587,7 @@ def unpause(name):
.format(name))}
return _change_state(name, 'unpause', 'running')
unfreeze = salt.utils.alias_function(unpause, 'unfreeze')

View file

@ -198,6 +198,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.alias_function(latest_version, 'available_version')
@ -484,6 +485,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.alias_function(remove, 'delete')
# No equivalent to purge packages, use remove instead

View file

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

View file

@ -91,6 +91,8 @@ def _represent_yaml_str(self, node):
Represent for yaml
'''
return self.represent_scalar(node)
YamlDumper.add_representer(u'tag:yaml.org,2002:str',
_represent_yaml_str)
YamlDumper.add_representer(u'tag:yaml.org,2002:timestamp',
@ -102,6 +104,8 @@ def _construct_yaml_str(self, node):
Construct for yaml
'''
return self.construct_scalar(node)
YamlLoader.add_constructor(u'tag:yaml.org,2002:timestamp',
_construct_yaml_str)

View file

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

View file

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

View file

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

View file

@ -2601,6 +2601,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.alias_function(destroy, 'remove')
@ -2945,6 +2946,7 @@ def set_password(name, users, password, encrypted=True, path=None):
)
return True
set_pass = salt.utils.alias_function(set_password, 'set_pass')
@ -4214,6 +4216,7 @@ def copy_to(name, source, dest, overwrite=False, makedirs=False, path=None):
overwrite=overwrite,
makedirs=makedirs)
cp = salt.utils.alias_function(copy_to, 'cp')
@ -4694,7 +4697,7 @@ def get_pid(name, path=None):
if name not in list_(limit='running', path=path):
raise CommandExecutionError('Container {0} is not running, can\'t determine PID'.format(name))
info = __salt__['cmd.run']('lxc-info -n {0}'.format(name)).split("\n")
pid = [line.split(':')[1].strip() for line in info if re.match(r'\s*PID', line) != None][0]
pid = [line.split(':')[1].strip() for line in info if re.match(r'\s*PID', line) is not None][0]
return pid

View file

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

View file

@ -175,6 +175,7 @@ def latest_version(*names, **kwargs):
return ret
# available_version is being deprecated
available_version = salt.utils.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.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.alias_function(decrement, 'decr')

View file

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

View file

@ -886,6 +886,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.alias_function(list_running, 'list_')
@ -1317,6 +1318,7 @@ def copy_to(name, source, dest, overwrite=False, makedirs=False):
overwrite=overwrite,
makedirs=makedirs)
cp = salt.utils.alias_function(copy_to, 'cp')
@ -1482,4 +1484,5 @@ def pull_dkr(url, name, index):
'''
return _pull_image('dkr', url, name, index=index)
pull_docker = salt.utils.alias_function(pull_dkr, 'pull_docker')

View file

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

View file

@ -212,6 +212,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.alias_function(version, 'info')
@ -1074,6 +1075,7 @@ def remove(name=None,
return ret
# Support pkg.delete to remove packages, since this is the CLI usage
delete = salt.utils.alias_function(remove, 'delete')
# No equivalent to purge packages, use remove instead

View file

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

View file

@ -617,6 +617,7 @@ def sync_output(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blackl
refresh_modules()
return ret
sync_outputters = salt.utils.alias_function(sync_output, 'sync_outputters')
@ -903,10 +904,11 @@ def refresh_pillar():
ret = False # Effectively a no-op, since we can't really return without an event system
return ret
pillar_refresh = salt.utils.alias_function(refresh_pillar, 'pillar_refresh')
def refresh_modules(async=True):
def refresh_modules(async=True): # pylint: disable=W8606
'''
Signal the minion to refresh the module and grain data
@ -921,7 +923,7 @@ def refresh_modules(async=True):
salt '*' saltutil.refresh_modules
'''
try:
if async:
if async: # pylint: disable=W8606
# If we're going to block, first setup a listener
ret = __salt__['event.fire']({}, 'module_refresh')
else:

View file

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

View file

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

View file

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

View file

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

View file

@ -4300,7 +4300,7 @@ def _writeAdminTemplateRegPolFile(admtemplate_data,
adml_policy_resources=None,
display_language='en-US',
registry_class='Machine'):
u'''
r'''
helper function to prep/write adm template data to the Registry.pol file
each file begins with REGFILE_SIGNATURE (u'\u5250\u6765') and

View file

@ -317,6 +317,7 @@ def hw_addr(iface):
'''
return salt.utils.network.hw_addr(iface)
# Alias hwaddr to preserve backward compat
hwaddr = salt.utils.alias_function(hw_addr, 'hwaddr')
@ -362,6 +363,7 @@ def ip_addrs(interface=None, include_loopback=False):
return salt.utils.network.ip_addrs(interface=interface,
include_loopback=include_loopback)
ipaddrs = salt.utils.alias_function(ip_addrs, 'ipaddrs')
@ -380,6 +382,7 @@ def ip_addrs6(interface=None, include_loopback=False):
return salt.utils.network.ip_addrs6(interface=interface,
include_loopback=include_loopback)
ipaddrs6 = salt.utils.alias_function(ip_addrs6, 'ipaddrs6')

View file

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

View file

@ -524,6 +524,7 @@ def latest_version(*names, **kwargs):
return ret[names[0]]
return ret
# available_version is being deprecated
available_version = salt.utils.alias_function(latest_version, 'available_version')
@ -917,6 +918,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.alias_function(list_upgrades, 'list_updates')
@ -2109,6 +2111,7 @@ def list_holds(pattern=__HOLD_PATTERN, full=True):
ret.append(match)
return ret
get_locked_packages = salt.utils.alias_function(list_holds, 'get_locked_packages')
@ -2416,6 +2419,7 @@ def group_install(name,
return install(pkgs=pkgs, **kwargs)
groupinstall = salt.utils.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

@ -431,6 +431,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.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

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

View file

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

View file

@ -134,6 +134,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

@ -95,6 +95,7 @@ def orchestrate(mods,
ret['retcode'] = 1
return ret
# Aliases for orchestrate runner
orch = salt.utils.alias_function(orchestrate, 'orch')
sls = salt.utils.alias_function(orchestrate, 'sls')

View file

@ -88,6 +88,7 @@ class Loader(BaseLoader): # pylint: disable=W0232
'''Overwrites Loader as not for pollute legacy Loader'''
pass
Loader.add_multi_constructor('tag:yaml.org,2002:null', Loader.construct_yaml_null)
Loader.add_multi_constructor('tag:yaml.org,2002:bool', Loader.construct_yaml_bool)
Loader.add_multi_constructor('tag:yaml.org,2002:int', Loader.construct_yaml_int)
@ -106,6 +107,7 @@ class Dumper(BaseDumper): # pylint: disable=W0232
'''Overwrites Dumper as not for pollute legacy Dumper'''
pass
Dumper.add_multi_representer(type(None), Dumper.represent_none)
Dumper.add_multi_representer(str, Dumper.represent_str)
if six.PY2:

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

@ -75,6 +75,8 @@ def _represent_yaml_str(self, node):
Represent for yaml
'''
return self.represent_scalar(node)
YamlDumper.add_representer(u'tag:yaml.org,2002:str',
_represent_yaml_str)
YamlDumper.add_representer(u'tag:yaml.org,2002:timestamp',
@ -86,6 +88,8 @@ def _construct_yaml_str(self, node):
Construct for yaml
'''
return self.construct_scalar(node)
YamlLoader.add_constructor(u'tag:yaml.org,2002:timestamp',
_construct_yaml_str)

View file

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

View file

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

View file

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

View file

@ -77,6 +77,7 @@ def computer_desc(name):
'\'{0}\''.format(name))
return ret
computer_description = salt.utils.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

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

View file

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

View file

@ -682,6 +682,7 @@ def ping_all_connected_minions(opts):
form = 'glob'
client.cmd(tgt, 'test.ping', tgt_type=form)
# test code for the ConCache class
if __name__ == '__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

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