Fix pylint errors and warnings

Remove `except` block which immediately raises the same exception again (it's
not a subclass of another caught exception, so this is safe).

Remove a false positive, because it is not emitted from the code base.

Disable subprocess-popen-preexec-fn in startProgram, which is not used
internally.
This commit is contained in:
Lars Karlitski 2018-09-17 12:03:21 +02:00 committed by Brian C. Lane
parent ca1bf01b03
commit d8cb1a19f8
5 changed files with 9 additions and 12 deletions

View File

@ -23,9 +23,11 @@ log = logging.getLogger("composer-cli")
import os
import sys
from composer import vernum
from composer.cli import main
from composer.cli.cmdline import composer_cli_parser
# Disable pylint warnings for these, because it cannot deal with this file and
# the module both being called "composer"
from composer import vernum # pylint: disable=import-self
from composer.cli import main # pylint: disable=no-name-in-module
from composer.cli.cmdline import composer_cli_parser # pylint: disable=no-name-in-module
VERSION = "{0}-{1}".format(os.path.basename(sys.argv[0]), vernum)

View File

@ -115,6 +115,7 @@ def startProgram(argv, root='/', stdin=None, stdout=subprocess.PIPE, stderr=subp
if env_add:
env.update(env_add)
# pylint: disable=subprocess-popen-preexec-fn
return subprocess.Popen(argv,
stdin=stdin,
stdout=stdout,

View File

@ -196,10 +196,7 @@ def loop_attach(outfile):
# Sometimes the loop device isn't ready yet, make extra sure before returning
loop_waitfor(dev, outfile)
except CalledProcessError:
# Problems running losetup are always errors, raise immediately
raise
except RuntimeError as e:
except RuntimeError:
# Try to setup the loop device 3 times
if retries == 3:
logger.error("loop_attach failed, retries exhausted.")

View File

@ -248,10 +248,10 @@ class LoraxTemplateRunner(object):
# skip the bit about "ltmpl.py, in _run()" - we know that
exclines.pop(1)
# log the "ErrorType: this is what happened" line
logger.error(" " + exclines[-1].strip())
logger.error(" %s", exclines[-1].strip())
# and log the entire traceback to the debug log
for _line in ''.join(exclines).splitlines():
logger.debug(" " + _line)
logger.debug(" %s", _line)
if self.fatalerrors:
raise

View File

@ -9,9 +9,6 @@ class LoraxLintConfig(PocketLintConfig):
PocketLintConfig.__init__(self)
self.falsePositives = [ FalsePositive(r"Module 'pylorax' has no 'version' member"),
# threading.Lock() is a factory function which returns an
# instance of the Lock class that is supported by the platform
FalsePositive(r"Context manager 'lock' doesn't implement __enter__ and __exit__"),
FalsePositive(r"Catching too general exception Exception"),
FalsePositive(r"^E0712.*: Catching an exception which doesn't inherit from (Base|)Exception: GError$"),
FalsePositive(r"Module 'composer' has no 'version' member"),