Skip to content

Commit

Permalink
migrate lint to python3
Browse files Browse the repository at this point in the history
Changing the lint environment to python3 introduces new pylint
messages. Most of them are solved by refactoring, some are
added to the disabled-list.

Signed-off-by: Alexander Graul <agraul@suse.com>
  • Loading branch information
agraul committed Apr 27, 2018
1 parent 0155302 commit 645f0a6
Show file tree
Hide file tree
Showing 23 changed files with 210 additions and 186 deletions.
45 changes: 22 additions & 23 deletions .pylintrc
Expand Up @@ -29,8 +29,7 @@ load-plugins=saltpylint.pep8,
saltpylint.thirdparty

# Use multiple processes to speed up Pylint.
# Don't bump this values on PyLint 1.4.0 - Know bug that ignores the passed --rcfile
jobs=1
jobs=5

# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
Expand Down Expand Up @@ -81,37 +80,37 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=W0142,
C0330,
I0011,
I0012,
W1202,
disable =
E1101,
E1320,
E1323,
E8402,
E8731,
W0141,
W1202,
W0141
# E8121,
# E8122,
# E8123,
# E8124,
# E8125,
# E8126,
# E8127,
# E8128
W8470,
C0330,
I0011,
I0012,
I1101

# Disabled Checks
#
# Errors
# E1101 (no-member)
# E1320 (un-indexed-curly-braces-error)
# E1323 (str-format-in-logging)
# E8402 (module-level-import-not-at-top-of-file)
# E8731 (do-not-assign-a-lambda-expression-use-a-def)
# Warnings
# W0142 (star-args)
# W1202 (logging-format-interpolation) Use % formatting in logging functions but pass the % parameters as arguments
# E812* All PEP8 E12*
# E8402 module level import not at top of file
# E8501 PEP8 line too long
# E8731 do not assign a lambda expression, use a def
# W1202 (logging-format-interpolation)
# W8470 (resource-leakage)
# Convention
# C0330 (bad-continuation)
# Other
# I0011 (locally-disabling)
# I0012 (locally-enabling)
# W1202 (logging-format-interpolation)
# I1101 (c-extension-no-member)


[REPORTS]
Expand Down
1 change: 1 addition & 0 deletions srv/modules/runners/cephprocesses.py
Expand Up @@ -179,6 +179,7 @@ def wait(cluster='ceph', **kwargs):
return True


# pylint: disable=no-else-return
def _timeout(cluster='ceph'):
"""
Assume 15 minutes for physical hardware since some hardware has long
Expand Down
1 change: 1 addition & 0 deletions srv/modules/runners/changed.py
Expand Up @@ -191,6 +191,7 @@ def has_change(self):
log.info("Change in configuration detected for role {}".format(self.role.name))
self.write_checksum(current_cs)
return True
return False


def help_():
Expand Down
6 changes: 3 additions & 3 deletions srv/modules/runners/disengage.py
Expand Up @@ -50,11 +50,11 @@ def check(cluster='ceph'):
Check that time stamp of file is less than one minute
"""
sff = SafetyFile(cluster)
stamp_recent = False
if os.path.exists(sff.filename):
stamp = os.stat(sff.filename).st_mtime
return stamp + 60 > time.time()
else:
return False
stamp_recent = stamp + 60 > time.time()
return stamp_recent

__func_alias__ = {
'help_': 'help',
Expand Down
11 changes: 6 additions & 5 deletions srv/modules/runners/filequeue.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# pylint: disable=visually-indented-line-with-same-indent-as-next-logical-line
# pylint: disable=too-few-public-methods,modernize-parse-error
# pylint: disable=too-few-public-methods,modernize-parse-error,no-else-return
"""
The queue runner in salt uses sqlite. While not a problem in general, when
a few events arrive simultaneously, the last attempts fail. The contention is
Expand Down Expand Up @@ -155,6 +155,7 @@ def vacate(self, item):
return False
else:
log.debug("filename {} does not exist".format(filename))
return None

def check(self, item):
"""
Expand Down Expand Up @@ -328,7 +329,7 @@ def enqueue(queue=None, **kwargs):
ret = filequeue.touch(kwargs['item'])
else:
help()
return
return None
return ret


Expand Down Expand Up @@ -415,7 +416,7 @@ def check(queue=None, **kwargs):
return filequeue.check(kwargs['item'])
else:
help()
return
return None


def remove(queue=None, **kwargs):
Expand All @@ -432,7 +433,7 @@ def remove(queue=None, **kwargs):
return filequeue.remove(kwargs['item'])
else:
help()
return
return None


def vacate(queue=None, **kwargs):
Expand All @@ -449,7 +450,7 @@ def vacate(queue=None, **kwargs):
return filequeue.vacate(kwargs['item'])
else:
help()
return
return None

__func_alias__ = {
'help_': 'help',
Expand Down
3 changes: 2 additions & 1 deletion srv/modules/runners/proposal.py
Expand Up @@ -207,6 +207,7 @@ def _choose_proposal(node, proposal, args):
return _propose(node, proposal[conf], args)
else:
log.error("Verify that targeted minions have proposal.generate")
return None


def help_():
Expand Down Expand Up @@ -299,7 +300,7 @@ def _record_filter(args, base_dir):
pprint.pprint(current_filter)

# filter a bunch of salt content and the target key before writing
rec_args = {k: v for k, v in args.items() if k is not 'target' and not
rec_args = {k: v for k, v in args.items() if k != 'target' and not
k.startswith('__')}
current_filter[args['target']] = rec_args

Expand Down
31 changes: 16 additions & 15 deletions srv/modules/runners/push.py
Expand Up @@ -59,8 +59,8 @@
import yaml
sys.path.append('/srv/modules/pillar')
# pylint: disable=import-error,3rd-party-module-not-gated,redefined-builtin,wrong-import-position
from stack import _merge_dict
import salt.ext.six as six
from stack import _merge_dict


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -242,12 +242,12 @@ def _custom(self, custom):
yml.write("# Overwrites configuration in {}\n".format(custom_for))
_examples(custom, yml)

def organize(self, filename):
def organize(self, policy_filename):
"""
Associate all filenames with their common subdirectory.
"""
common = {}
with open(filename, "r") as policy:
with open(policy_filename, "r") as policy:
for line in policy:
log.debug(line)
# strip comments from the end of the line
Expand All @@ -257,27 +257,28 @@ def organize(self, filename):
log.debug("Ignoring '{}'".format(line))
continue
try:
files = _parse(self.proposals_dir + "/" + line)
proposal_files = _parse(self.proposals_dir + "/" + line)
except ValueError:
log.exception('''
ERROR: Mailformed {}: {}
'''.format(filename, line))
files = []
if not files:
'''.format(policy_filename, line))
proposal_files = []
if not proposal_files:
log.warning("{} matched no files".format(line))
log.debug(line)
log.debug(files)
for filename in files:
if os.stat(filename).st_size == 0:
log.warning("Skipping empty file {}".format(filename))
log.debug(proposal_files)
for proposal_file in proposal_files:
if os.stat(proposal_file).st_size == 0:
log.warning("Skipping empty file {}".format(proposal_file))
continue
if os.path.isfile(filename):
pathname = _shift_dir(filename.replace(self.proposals_dir, ""))
if os.path.isfile(proposal_file):
pathname = _shift_dir(proposal_file.replace(
self.proposals_dir, ""))
if pathname not in common:
common[pathname] = []
common[pathname].append(filename)
common[pathname].append(proposal_file)
else:
log.warning("{} does not exist".format(filename))
log.warning("{} does not exist".format(proposal_file))

# This should be in a conditional, but
# getEffectiveLevel returns 1 no matter setting
Expand Down
6 changes: 2 additions & 4 deletions srv/modules/runners/select.py
Expand Up @@ -91,11 +91,9 @@ def one_minion(**kwargs):
Some steps only need to be run once, but on any minion in a specific
search. Return the first matching key.
"""
ret = [None]
ret = minions(**kwargs)
if ret:
return ret[0]
else:
return
return ret[0]


def public_addresses(tuples=False, host=False, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions srv/modules/runners/status.py
Expand Up @@ -39,6 +39,7 @@ def help_():
return ""


# pylint: disable=no-else-return
def report(cluster_name='ceph', stdout=True, return_data=False):
"""
Creates a report that tries to find the most common versions from:
Expand Down
1 change: 1 addition & 0 deletions srv/modules/runners/ui_ganesha.py
Expand Up @@ -178,6 +178,7 @@ def write_block_body(block, depth=0):
"""
Return the block body
"""
# pylint: disable=no-else-return
def format_val(key, val):
"""
Return a comma separated list, raw value or quoted value
Expand Down
18 changes: 10 additions & 8 deletions srv/modules/runners/ui_iscsi.py
Expand Up @@ -56,6 +56,7 @@ def populate(self):

return self.data

# pylint: disable=no-else-return
def interfaces(self, wrapped=True):
"""
Parse grains for all network interfaces on igw roles. Possibly
Expand Down Expand Up @@ -104,15 +105,15 @@ def config(self, filename="/srv/salt/ceph/igw/cache/lrbd.conf"):
"""
Read the existing lrbd.conf
"""
lrbd_conf = {
'auth': [],
'targets': [],
'portals': [],
'pools': []
}
if os.path.exists(filename):
return json.loads(open(filename).read())
else:
return {
'auth': [],
'targets': [],
'portals': [],
'pools': []
}
lrbd_conf = json.loads(open(filename).read())
return lrbd_conf

def save(self, filename="/srv/salt/ceph/igw/cache/lrbd.conf", **kwargs):
"""
Expand Down Expand Up @@ -178,6 +179,7 @@ def canned_populate(self, canned):

return self.data

# pylint: disable=no-else-return
def canned_images(self, canned, wrapped=True):
"""
Return canned example for pools and images
Expand Down

0 comments on commit 645f0a6

Please sign in to comment.