[elbe-devel] [PATCH v2 25/66] treeutils: Fix Pylint

Torben Hohn torben.hohn at linutronix.de
Wed Jun 10 13:33:24 CEST 2020


On Fri, Jun 05, 2020 at 01:06:49PM -0400, Olivier Dion wrote:
> 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>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/treeutils.py | 26 ++++++++------------------
>  1 file changed, 8 insertions(+), 18 deletions(-)
> 
> diff --git a/elbepack/treeutils.py b/elbepack/treeutils.py
> index 16308a42..75a1c857 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,18 +147,10 @@ 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):
> -        attr = node.get(attributename)
> -        if attr is None:
> -            return False
> -        elif attr in ['true', '1']:
> -            return True
> -        elif attr in ['false', '0']:
> -            return False
> -
>      @property
>      def root(self):
>          return elem(self.et.getroot())
> -- 
> 2.27.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list