[elbe-devel] [PATCH 31/75] treeutils: Fix Pylint
Olivier Dion
dion at linutronix.de
Mon May 25 17:42:24 CEST 2020
16:0: R0205: (useless-object-inheritance)
37:0: R0205: (useless-object-inheritance)
60:8: R1705: (no-else-return)
109:8: R1705: (no-else-return)
107:4: R1710: (inconsistent-return-statements)
152:8: W0212: (protected-access)
157:8: R1705: (no-else-return)
155:4: R1710: (inconsistent-return-statements)
155:4: R0201: (no-self-use)
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/treeutils.py | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/elbepack/treeutils.py b/elbepack/treeutils.py
index 16308a42..8171cf5c 100644
--- a/elbepack/treeutils.py
+++ b/elbepack/treeutils.py
@@ -13,6 +13,8 @@ from lxml.etree import XMLParser, parse
# ElementTree helpers
+# TODO:py3 Remove object inheritance
+# pylint: disable=useless-object-inheritance
class eiter(object):
def __init__(self, it):
self.it = it
@@ -33,7 +35,8 @@ class eiter(object):
def next(self):
return self.__next__()
-
+# TODO:py3 Remove object inheritance
+# pylint: disable=useless-object-inheritance
class ebase(object):
def __init__(self, et):
self.et = et
@@ -59,8 +62,7 @@ class ebase(object):
retval = self.et.find("./" + path)
if retval is not None:
return elem(retval)
- else:
- return None
+ return None
def all(self, path):
return map(elem, self.et.findall(path))
@@ -106,12 +108,9 @@ class elem(ebase):
def bool_attr(self, attrname):
attr = self.et.attrib.get(attrname)
- if attr is None:
- return False
- elif attr in ['true', '1']:
+ if attr in ('true', '1'):
return True
- elif attr in ['false', '0']:
- return False
+ return False
def get_parent(self):
return elem(self.et.getparent())
@@ -139,7 +138,6 @@ class etree(ebase):
retval = self.et.find("./" + tag)
if retval is not None:
return elem(retval)
-
return elem(SubElement(self.et.getroot(), tag))
def set_child_position(self, child, pos):
@@ -149,17 +147,17 @@ class etree(ebase):
def setroot(self, tag):
retval = elem(Element(tag))
+ # pylint: disable=protected-access
self.et._setroot(retval.et)
return retval
- def check_boolean(self, node, attributename):
+ # TODO - Remove? This method is never used in Elbe.
+ @staticmethod
+ def check_boolean(node, attributename):
attr = node.get(attributename)
- if attr is None:
- return False
- elif attr in ['true', '1']:
+ if attr in ('true', '1'):
return True
- elif attr in ['false', '0']:
- return False
+ return False
@property
def root(self):
--
2.26.2
More information about the elbe-devel
mailing list