[PATCH 0/7] pylint fixes

97 views
Skip to first unread message

Daniel Wagner

unread,
Jul 18, 2018, 10:29:00 AM7/18/18
to kas-...@googlegroups.com, Daniel Wagner
A new version of pylint is complaining about stuff. Fix it.

Daniel Wagner (7):
includehandler: Remove useless object inheritance
includehandler: Silence too-many-arguments pyling warning
test_includehandler: Remove useless object inheritanc
test_includehandler: Fix indention
repos: Fix unnecessary "else" after "return"
libkas: Disable not-an-itable false positive
pylint: Disable too-many-statements

.pylintrc | 3 ++-
kas/includehandler.py | 4 +++-
kas/libkas.py | 4 ++++
kas/repos.py | 14 +++++++-------
tests/test_includehandler.py | 16 +++++++++-------
5 files changed, 25 insertions(+), 16 deletions(-)

--
2.17.1

Daniel Wagner

unread,
Jul 18, 2018, 10:29:01 AM7/18/18
to kas-...@googlegroups.com, Daniel Wagner
pylint reports:

kas/includehandler.py:105:0: R0205: Class 'IncludeHandler' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)

Signed-off-by: Daniel Wagner <daniel...@siemens.com>
---
kas/includehandler.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kas/includehandler.py b/kas/includehandler.py
index c608eaae3e78..abba789616ab 100644
--- a/kas/includehandler.py
+++ b/kas/includehandler.py
@@ -102,7 +102,7 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017'
pass


-class IncludeHandler(object):
+class IncludeHandler:
"""
Abstract class that defines the interface of an include handler.
"""
--
2.17.1

Daniel Wagner

unread,
Jul 18, 2018, 10:29:02 AM7/18/18
to kas-...@googlegroups.com, Daniel Wagner
pylint has a bug:

https://github.com/PyCQA/pylint/issues/996

Signed-off-by: Daniel Wagner <daniel...@siemens.com>
---
kas/libkas.py | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kas/libkas.py b/kas/libkas.py
index 82470620c635..42d4ddc4ff61 100644
--- a/kas/libkas.py
+++ b/kas/libkas.py
@@ -88,6 +88,10 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017'
"""
# pylint: disable=too-many-arguments

+ # Disable incorrect warning on asyncio.wait_for,
+ # https://github.com/PyCQA/pylint/issues/996.
+ # pylint: disable=not-an-iterable
+
env = env or {}
cmdstr = cmd
if not shell:
--
2.17.1

Daniel Wagner

unread,
Jul 18, 2018, 10:29:02 AM7/18/18
to kas-...@googlegroups.com, Daniel Wagner
pylint reports:

kas/repos.py:53:8: R1705: Unnecessary "else" after "return" (no-else-return)
kas/repos.py:264:12: R1705: Unnecessary "else" after "return" (no-else-return)

Signed-off-by: Daniel Wagner <daniel...@siemens.com>
---
kas/repos.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kas/repos.py b/kas/repos.py
index c5d1ce3df083..2e44babdbb67 100644
--- a/kas/repos.py
+++ b/kas/repos.py
@@ -50,6 +50,7 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017'
self.operations_disabled = disable_operations

def __getattr__(self, item):
+ # pylint: disable=no-else-return
if item == 'layers':
if not self._layers:
return [self.path]
@@ -62,9 +63,8 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017'
.replace(':', '.')
.replace('/', '.')
.replace('*', '.'))
- else:
- # Default behaviour
- raise AttributeError
+ # Default behaviour
+ raise AttributeError

def __str__(self):
return '%s:%s %s %s' % (self.url, self.refspec,
@@ -267,10 +267,10 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017'
'entry: %s, vcs output: %s)',
path, self.name, patch['id'], output)
return 1
- else:
- logging.info('Patch applied. '
- '(patch path: %s, repo: %s, patch entry: %s)',
- path, self.name, patch['id'])
+
+ logging.info('Patch applied. '
+ '(patch path: %s, repo: %s, patch entry: %s)',
+ path, self.name, patch['id'])
return 0


--
2.17.1

Daniel Wagner

unread,
Jul 18, 2018, 10:29:02 AM7/18/18
to kas-...@googlegroups.com, Daniel Wagner
Signed-off-by: Daniel Wagner <daniel...@siemens.com>
---
.pylintrc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.pylintrc b/.pylintrc
index a6e4db1d001e..4ceefd8dada9 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -65,7 +65,8 @@ 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,redefined-variable-type
+disable=too-few-public-methods,locally-disabled,redefined-variable-type,too-many-statements
+


[REPORTS]
--
2.17.1

Daniel Wagner

unread,
Jul 18, 2018, 10:29:02 AM7/18/18
to kas-...@googlegroups.com, Daniel Wagner
Signed-off-by: Daniel Wagner <daniel...@siemens.com>
---
kas/includehandler.py | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kas/includehandler.py b/kas/includehandler.py
index abba789616ab..905ea3d55c94 100644
--- a/kas/includehandler.py
+++ b/kas/includehandler.py
@@ -174,6 +174,8 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017'
the current file overwrites every include. (evaluation depth first
and from top to buttom)
"""
+ # pylint: disable=too-many-arguments
+
missing_repos = []
configs = []
current_config = load_config(filename)
--
2.17.1

Daniel Wagner

unread,
Jul 18, 2018, 10:29:02 AM7/18/18
to kas-...@googlegroups.com, Daniel Wagner
Signed-off-by: Daniel Wagner <daniel...@siemens.com>
---
tests/test_includehandler.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test_includehandler.py b/tests/test_includehandler.py
index 5046e8d8d08b..ed1fe31d9742 100644
--- a/tests/test_includehandler.py
+++ b/tests/test_includehandler.py
@@ -59,7 +59,7 @@ from kas import includehandler
del component.open


-class TestLoadConfig(object):
+class TestLoadConfig:
def test_err_invalid_ext(self):
# Test for invalid file extension:
exception = includehandler.LoadConfigException
@@ -129,7 +129,7 @@ from kas import includehandler
includehandler.load_config('x.yml')


-class TestGlobalIncludes(object):
+class TestGlobalIncludes:
header = '''
header:
version: 5
--
2.17.1

Daniel Wagner

unread,
Jul 18, 2018, 10:29:02 AM7/18/18
to kas-...@googlegroups.com, Daniel Wagner
pylint reports

tests/test_includehandler.py:343:0: C0330: Wrong hanging indentation before block (add 4 spaces).
'x.yml': header.format(''' includes: ["y.yml", "z.yml"]
^ | (bad-continuation)
tests/test_includehandler.py:345:0: C0330: Wrong hanging indentation before block (add 4 spaces).
os.path.abspath('y.yml'): header.format(''' includes: ["z.yml"]
^ | (bad-continuation)
tests/test_includehandler.py:347:0: C0330: Wrong hanging indentation before block (add 4 spaces).
os.path.abspath('z.yml'): header.format('''
^ | (bad-continuation)

Signed-off-by: Daniel Wagner <daniel...@siemens.com>
---
tests/test_includehandler.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/test_includehandler.py b/tests/test_includehandler.py
index ed1fe31d9742..82c61e437074 100644
--- a/tests/test_includehandler.py
+++ b/tests/test_includehandler.py
@@ -339,13 +339,15 @@ v2: y
# disable schema validation for this test:
monkeypatch.setattr(includehandler, 'CONFIGSCHEMA', {})
header = self.__class__.header
- with patch_open(includehandler, dictionary={
- 'x.yml': header.format(''' includes: ["y.yml", "z.yml"]
+ data = {'x.yml':
+ header.format(''' includes: ["y.yml", "z.yml"]
v: {v1: x, v2: x}'''),
- os.path.abspath('y.yml'): header.format(''' includes: ["z.yml"]
+ os.path.abspath('y.yml'):
+ header.format(''' includes: ["z.yml"]
v: {v2: y, v3: y, v5: y}'''),
- os.path.abspath('z.yml'): header.format('''
-v: {v3: z, v4: z}''')}):
+ os.path.abspath('z.yml'): header.format('''
+v: {v3: z, v4: z}''')}
+ with patch_open(includehandler, dictionary=data):
ginc = includehandler.GlobalIncludes('x.yml')
config, _ = ginc.get_config()
keys = list(config['v'].keys())
--
2.17.1

Claudius Heine

unread,
Jul 18, 2018, 3:25:42 PM7/18/18
to Daniel Wagner, kas-...@googlegroups.com
Hi,

IMO it would be nice to see the error(s) that is/are silenced in the
commit message and some justification why disabling those globally is
the correct solution.

That makes review easier.

Thanks,
Claudius
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: c...@denx.de

PGP key: 6FF2 E59F 00C6 BC28 31D8 64C1 1173 CB19 9808 B153
Keyserver: hkp://pool.sks-keyservers.net
signature.asc

Daniel Wagner

unread,
Jul 19, 2018, 3:26:22 AM7/19/18
to kas-...@googlegroups.com, Daniel Wagner
pylint reports

kas/includehandler.py:148:4: R0915: Too many statements (58/50) (too-many-statements)

All attempts to silence via a local disable didn't work, so disable it
on a global level. There is little value in this warning anyway.

Signed-off-by: Daniel Wagner <daniel...@siemens.com>
---
.pylintrc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.pylintrc b/.pylintrc
index a6e4db1d001e..4ceefd8dada9 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -65,7 +65,8 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
Reply all
Reply to author
Forward
0 new messages