From 546b51f450d8b873d694f34cb5df1c7a238255f0 Mon Sep 17 00:00:00 2001 From: Claudius Heine Date: Wed, 28 Jun 2017 14:48:40 +0200 Subject: [PATCH] Fixed issues that occured with pylint 1.7.2 When updating the previously used version of pylint 1.6.5 to 1.7.2 some new issues where found. This patch fixes these issues: ************* Module kas.config E:402, 0: Bad option value 'redefined-variable-type' (bad-option-value) ************* Module kas.includehandler E: 33, 0: No name 'version' in module 'distutils' (no-name-in-module) E: 33, 0: Unable to import 'distutils.version' (import-error) R:239,12: Unnecessary "else" after "return" (no-else-return) ************* Module kas.libkas C:214, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) ************* Module kas.repos R: 54,12: Unnecessary "else" after "return" (no-else-return) Signed-off-by: Claudius Heine --- .pylintrc | 2 +- kas/config.py | 1 - kas/includehandler.py | 24 ++++++++++++++---------- kas/libkas.py | 2 +- kas/repos.py | 3 +-- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.pylintrc b/.pylintrc index 20c2ad2..a6e4db1 100644 --- a/.pylintrc +++ b/.pylintrc @@ -65,7 +65,7 @@ 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=too-few-public-methods,locally-disabled +disable=too-few-public-methods,locally-disabled,redefined-variable-type [REPORTS] diff --git a/kas/config.py b/kas/config.py index fbe1fd3..d755637 100644 --- a/kas/config.py +++ b/kas/config.py @@ -406,7 +406,6 @@ def load_config(filename, target): """ Return configuration generated from `filename`. """ - # pylint: disable=redefined-variable-type (_, ext) = os.path.splitext(filename) if ext == '.py': diff --git a/kas/includehandler.py b/kas/includehandler.py index 1f1065a..5bf318b 100644 --- a/kas/includehandler.py +++ b/kas/includehandler.py @@ -30,7 +30,12 @@ import sys import collections import functools import logging -from distutils.version import StrictVersion +try: + # pylint: disable=no-name-in-module + from distutils.version import StrictVersion +except ImportError as exc: + logging.error("Could not import StrictVersion") + raise exc from . import __version__, __compatible_version__ @@ -250,15 +255,14 @@ class GlobalIncludes(IncludeHandler): else: dest[key] = upd[key] return dest - else: - try: - for k in upd: - dest[k] = upd[k] - except AttributeError: - # this mapping is not a dict - for k in upd: - dest[k] = upd[k] - return dest + try: + for k in upd: + dest[k] = upd[k] + except AttributeError: + # this mapping is not a dict + for k in upd: + dest[k] = upd[k] + return dest configs, missing_repos = _internal_include_handler(self.top_file) config = functools.reduce(_internal_dict_merge, diff --git a/kas/libkas.py b/kas/libkas.py index 8b9b4f8..9487c6c 100644 --- a/kas/libkas.py +++ b/kas/libkas.py @@ -220,7 +220,7 @@ def repo_checkout(config, repo): (_, output) = run_cmd(['/usr/bin/git', 'diff', '--shortstat'], env=config.environ, cwd=repo.path, fail=False) - if len(output): + if output: logging.warning('Repo %s is dirty. no checkout', repo.name) return diff --git a/kas/repos.py b/kas/repos.py index 6b85e94..047c803 100644 --- a/kas/repos.py +++ b/kas/repos.py @@ -53,8 +53,7 @@ class Repo: if item == 'layers': if not self._layers: return [self.path] - else: - return [self.path + '/' + l for l in self._layers] + return [self.path + '/' + l for l in self._layers] elif item == 'qualified_name': url = urlparse(self.url) return ('{url.netloc}{url.path}'