Blob Blame History Raw
From 93eebf4daf020c7aacd191b580a1507677957c29 Mon Sep 17 00:00:00 2001
From: Julius Milan <jmilan@redhat.com>
Date: Wed, 31 May 2017 11:44:54 +0200
Subject: [PATCH] Satisfy pylint v1.7.1 warnings

Adapts the code to satisfy new pylint's warnings:

C1801 "len-as-condition": pylint requires to use the fact that empty
sequences (strings, lists, tuples) are false. i.e.:

ok:  if not seq:
     if seq:

bad: if len(seq):
     if not len(seq):

W0235 "useless-super-delegation": occurs when overriden method does the
same thing as its base method. (in conjunction with super())
---
 src/gnome-abrt                       | 6 +++---
 src/gnome_abrt/dbus_problems.py      | 5 +----
 src/gnome_abrt/directory_problems.py | 2 +-
 src/gnome_abrt/errors.py             | 4 +---
 src/gnome_abrt/problems.py           | 4 ++--
 src/gnome_abrt/url/gliburltitle.py   | 2 +-
 6 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/gnome-abrt b/src/gnome-abrt
index 4b9e46b..f8e96e8 100755
--- a/src/gnome-abrt
+++ b/src/gnome-abrt
@@ -163,7 +163,7 @@ class GtkAppDBUSImpl(object):
                 self._primary_iface = dbus.Interface(self._primary_obj,
                         GNOME_ABRT_INTERFACE)
 
-            if len(argv) == 0:
+            if not argv:
                 argv = dbus.Array([], signature='s')
 
             self._primary_iface.command_line(argv)
@@ -232,7 +232,7 @@ class OopsApplication(Gtk.Application):
             if self._dbus_srv.send_command_line(argv):
                 return 0
 
-        if len(argv) > 0:
+        if argv:
             conf = get_configuration()
             conf['problemid'] = argv[0]
 
@@ -265,7 +265,7 @@ class OopsApplication(Gtk.Application):
                 except UnavailableSource:
                     logging.warning(str(ex))
 
-                if len(sources) == 0:
+                if not sources:
                     raise UnavailableSource(None, None,
                             message="No available problem source.")
 
diff --git a/src/gnome_abrt/dbus_problems.py b/src/gnome_abrt/dbus_problems.py
index 7be6179..89f092e 100644
--- a/src/gnome_abrt/dbus_problems.py
+++ b/src/gnome_abrt/dbus_problems.py
@@ -157,7 +157,7 @@ class DBusProblemSource(problems.CachedSource):
     def get_items(self, problem_id, *args):
         info = {}
 
-        if len(args) != 0:
+        if args:
             try:
                 info = self._send_dbus_message(
                         lambda iface, *params: iface.GetInfo(*params),
@@ -261,9 +261,6 @@ class StandardProblems(DBusProblemSource.Driver):
 
 class ForeignProblems(DBusProblemSource.Driver):
 
-    def __init__(self, source):
-        super(ForeignProblems, self).__init__(source)
-
     @property
     def get_problems_method(self):
         return lambda iface, *args: iface.GetForeignProblems(*args)
diff --git a/src/gnome_abrt/directory_problems.py b/src/gnome_abrt/directory_problems.py
index 772cbaa..02a06ed 100644
--- a/src/gnome_abrt/directory_problems.py
+++ b/src/gnome_abrt/directory_problems.py
@@ -253,7 +253,7 @@ class InitializedDirectoryProblemSource(object):
         self._watcher = INOTIFYWatcher(self._parent, self.directory, context)
 
     def get_items(self, problem_id, *args):
-        if len(args) == 0:
+        if not args:
             return {}
 
         dd = report.dd_opendir(problem_id, report.DD_OPEN_READONLY)
diff --git a/src/gnome_abrt/errors.py b/src/gnome_abrt/errors.py
index 777b85e..2f4d44e 100644
--- a/src/gnome_abrt/errors.py
+++ b/src/gnome_abrt/errors.py
@@ -16,9 +16,7 @@
 ## Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335  USA
 
 class GnomeAbrtError(Exception):
-
-    def __init__(self, message=None):
-        super(GnomeAbrtError, self).__init__(message)
+    pass
 
 class InvalidProblem(GnomeAbrtError):
 
diff --git a/src/gnome_abrt/problems.py b/src/gnome_abrt/problems.py
index e918994..fbde9ac 100644
--- a/src/gnome_abrt/problems.py
+++ b/src/gnome_abrt/problems.py
@@ -284,7 +284,7 @@ class Problem(object):
                 # Most common type of line in reported_to file
                 # Bugzilla: URL=http://bugzilla.com/?=123456
                 for line in self['reported_to'].split('\n'):
-                    if len(line) == 0:
+                    if not line:
                         continue
 
                     pfx_lst = []
@@ -328,7 +328,7 @@ class MultipleSources(ProblemSource):
     def __init__(self, sources):
         super(MultipleSources, self).__init__()
 
-        if len(sources) == 0:
+        if not sources:
             raise ValueError("At least one source must be passed")
 
         self.sources = sources
diff --git a/src/gnome_abrt/url/gliburltitle.py b/src/gnome_abrt/url/gliburltitle.py
index 79b61e4..44c7a6c 100644
--- a/src/gnome_abrt/url/gliburltitle.py
+++ b/src/gnome_abrt/url/gliburltitle.py
@@ -110,7 +110,7 @@ class GetURLTitleSourcePool(object):
             userdata[0](result, userdata[1])
         finally:
             self._running -= 1
-            if len(self._defered):
+            if self._defered:
                 url, readycallback, userdata = self._defered.pop()
                 self._start_resolving(url, readycallback, userdata)
 
-- 
2.7.5