[PATCH rhel7-branch] Pass the pylint test.

Chris Lumens clumens at redhat.com
Fri Jun 5 20:44:28 UTC 2015


Note that a couple of these were actual bugs - _protocols is a tuple so you
can't pop from that.  Displaying the name of the ostree root in rescue mode
was incorrect.  on_apply_clicked has been renamed to on_update_settings_clicked.
---
 pyanaconda/bootloader.py                               | 3 ---
 pyanaconda/installclasses/fedora.py                    | 2 --
 pyanaconda/installclasses/rhel.py                      | 1 -
 pyanaconda/isys/__init__.py                            | 9 ---------
 pyanaconda/packaging/rpmostreepayload.py               | 4 +++-
 pyanaconda/rescue.py                                   | 4 ++--
 pyanaconda/ui/__init__.py                              | 7 ++-----
 pyanaconda/ui/categories/__init__.py                   | 1 -
 pyanaconda/ui/gui/__init__.py                          | 4 ++--
 pyanaconda/ui/gui/hubs/__init__.py                     | 4 ----
 pyanaconda/ui/gui/spokes/__init__.py                   | 1 -
 pyanaconda/ui/gui/spokes/custom.py                     | 4 ++--
 pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py | 4 +---
 pyanaconda/ui/gui/spokes/lib/passphrase.py             | 2 +-
 pyanaconda/ui/tui/simpleline/base.py                   | 8 ++++----
 pyanaconda/ui/tui/spokes/langsupport.py                | 2 --
 pyanaconda/ui/tui/spokes/source.py                     | 4 +++-
 pyanaconda/ui/tui/spokes/user.py                       | 2 +-
 pyanaconda/ui/tui/tuiobject.py                         | 9 ---------
 pyanaconda/users.py                                    | 2 +-
 tests/pyanaconda_tests/localization_test.py            | 2 +-
 tests/pylint/pylint-false-positives                    | 1 +
 22 files changed, 24 insertions(+), 56 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 6d083b9..fb0529b 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1392,10 +1392,7 @@ class GRUB2(GRUB):
     packages = ["grub2"]
     _config_file = "grub.cfg"
     _config_dir = "grub2"
-    config_file_mode = 0o600
     defaults_file = "/etc/default/grub"
-    can_dual_boot = True
-    can_update = True
     terminal_type = "console"
 
     # requirements for boot devices
diff --git a/pyanaconda/installclasses/fedora.py b/pyanaconda/installclasses/fedora.py
index d176582..df26df0 100644
--- a/pyanaconda/installclasses/fedora.py
+++ b/pyanaconda/installclasses/fedora.py
@@ -30,8 +30,6 @@ class FedoraBaseInstallClass(BaseInstallClass):
 
     _l10n_domain = "anaconda"
 
-    installUpdates = True
-
     efi_dir = "fedora"
 
     help_placeholder = "FedoraPlaceholder.html"
diff --git a/pyanaconda/installclasses/rhel.py b/pyanaconda/installclasses/rhel.py
index ececad0..be9135b 100644
--- a/pyanaconda/installclasses/rhel.py
+++ b/pyanaconda/installclasses/rhel.py
@@ -35,7 +35,6 @@ class RHELBaseInstallClass(BaseInstallClass):
     defaultFS = "xfs"
 
     bootloaderTimeoutDefault = 5
-    bootloaderExtraArgs = []
 
     ignoredPackages = ["ntfsprogs", "reiserfs-utils", "hfsplus-tools"]
 
diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py
index 9153704..bba075b 100644
--- a/pyanaconda/isys/__init__.py
+++ b/pyanaconda/isys/__init__.py
@@ -29,16 +29,7 @@ except ImportError:
     # up PYTHONPATH and just do this basic import.
     import _isys
 
-import os
-import os.path
-import socket
-import stat
-import sys
-from pyanaconda import iutil
 import blivet.arch
-import re
-import struct
-import dbus
 import time
 import datetime
 import pytz
diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py
index 3eeb2b1..c9e190d 100644
--- a/pyanaconda/packaging/rpmostreepayload.py
+++ b/pyanaconda/packaging/rpmostreepayload.py
@@ -21,7 +21,6 @@
 #
 
 import os
-import shutil
 import sys
 
 from pyanaconda import constants
@@ -44,6 +43,9 @@ class RPMOSTreePayload(ArchivePayload):
     def __init__(self, data):
         super(RPMOSTreePayload, self).__init__(data)
 
+        self._base_remote_args = None
+        self._sysroot_path = None
+
     @property
     def handlesBootloaderConfiguration(self):
         return True
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index 446c2e3..17901a5 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -280,7 +280,7 @@ def findExistingOstreePartitions(devicetree):
             continue
 
         name = _("Ostree on %s") % device.name
-        roots.append(blivet.Root(mounts=None, swaps=None, name=device.name))
+        roots.append(blivet.Root(mounts=None, swaps=None, name=name))
 
     return roots
 
@@ -462,7 +462,7 @@ def doRescue(intf, rescue_mount, ksdata):
                     pass
         except (ValueError, LookupError, SyntaxError, NameError):
             raise
-        except Exception as e:
+        except Exception as e:    # pylint: disable=broad-except
             log.error("doRescue caught exception: %s", e)
             if flags.automatedInstall:
                 log.error("An error occurred trying to mount some or all of your system")
diff --git a/pyanaconda/ui/__init__.py b/pyanaconda/ui/__init__.py
index b1eb060..2686ded 100644
--- a/pyanaconda/ui/__init__.py
+++ b/pyanaconda/ui/__init__.py
@@ -22,7 +22,6 @@
 __all__ = ["UserInterface"]
 
 import copy
-import os
 from pyanaconda.ui.common import collect
 
 class PathDict(dict):
@@ -73,8 +72,6 @@ class UserInterface(object):
         errorHandler.ui = self
 
 
-    basepath = os.path.dirname(__file__)
-    basemask = "pyanaconda.ui"
     paths = PathDict({})
 
     @property
@@ -176,10 +173,10 @@ class UserInterface(object):
 
         actionClasses = []
         for hub in hubs:
-            actionClasses.extend(sorted(filter(lambda obj: getattr(obj, "preForHub", None) == hub, spokes),
+            actionClasses.extend(sorted(filter(lambda obj, h=hub: getattr(obj, "preForHub", None) == h, spokes),
                                         key=lambda obj: obj.priority))
             actionClasses.append(hub)
-            actionClasses.extend(sorted(filter(lambda obj: getattr(obj, "postForHub", None) == hub, spokes),
+            actionClasses.extend(sorted(filter(lambda obj, h=hub: getattr(obj, "postForHub", None) == h, spokes),
                                         key=lambda obj: obj.priority))
 
         return actionClasses
diff --git a/pyanaconda/ui/categories/__init__.py b/pyanaconda/ui/categories/__init__.py
index 6a0e270..5fa3ccd 100644
--- a/pyanaconda/ui/categories/__init__.py
+++ b/pyanaconda/ui/categories/__init__.py
@@ -19,7 +19,6 @@
 # Red Hat Author(s): Chris Lumens <clumens at redhat.com>
 #
 
-import os.path
 from pyanaconda.i18n import N_
 
 __all__ = ["SpokeCategory"]
diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index c734ba8..42b28fb 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -30,7 +30,7 @@ from pyanaconda.constants import IPMI_ABORTED
 from pyanaconda import product, iutil
 
 from pyanaconda.ui import UserInterface, common
-from pyanaconda.ui.gui.utils import gtk_action_wait, busyCursor, unbusyCursor
+from pyanaconda.ui.gui.utils import gtk_action_wait, unbusyCursor
 from pyanaconda import ihelp
 import os.path
 
@@ -817,7 +817,7 @@ class GraphicalUserInterface(UserInterface):
         # content for the current screen
         ihelp.start_yelp(ihelp.get_help_path(obj.helpFile, self.instclass))
 
-    def _on_mnemonics_visible_changed(self, window, property, obj):
+    def _on_mnemonics_visible_changed(self, window, property_type, obj):
         # mnemonics display has been activated or deactivated,
         # add or remove the F1 mnemonics display from the help button
         help_button = obj.window.get_help_button()
diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py
index 88c52bb..cb24585 100644
--- a/pyanaconda/ui/gui/hubs/__init__.py
+++ b/pyanaconda/ui/gui/hubs/__init__.py
@@ -19,8 +19,6 @@
 # Red Hat Author(s): Chris Lumens <clumens at redhat.com>
 #
 
-import os
-
 from gi.repository import GLib
 
 from pyanaconda.flags import flags
@@ -29,9 +27,7 @@ from pyanaconda.product import distributionText
 
 from pyanaconda.ui import common
 from pyanaconda.ui.gui import GUIObject
-from pyanaconda.ui.gui.spokes import StandaloneSpoke
 from pyanaconda.ui.gui.utils import gtk_call_once, escape_markup
-from pyanaconda.constants import ANACONDA_ENVIRON
 
 import logging
 log = logging.getLogger("anaconda")
diff --git a/pyanaconda/ui/gui/spokes/__init__.py b/pyanaconda/ui/gui/spokes/__init__.py
index f17b71c..1227d44 100644
--- a/pyanaconda/ui/gui/spokes/__init__.py
+++ b/pyanaconda/ui/gui/spokes/__init__.py
@@ -21,7 +21,6 @@
 
 from pyanaconda.ui import common
 from pyanaconda.ui.gui import GUIObject
-import os.path
 from pyanaconda import ihelp
 
 __all__ = ["StandaloneSpoke", "NormalSpoke"]
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index dc35efc..64df7da 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -2019,7 +2019,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
 
         log.debug("%s -> %s", container_name, self._device_container_name)
         if container_name == self._device_container_name:
-            self.on_apply_clicked(None)
+            self.on_update_settings_clicked(None)
             return
 
         log.debug("renaming container %s to %s", container_name, self._device_container_name)
@@ -2057,7 +2057,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         self._containerStore.remove(self._containerStore.get_iter_from_string("%s" % (idx + 1)))
 
         self._update_selectors()
-        self.on_apply_clicked(None)
+        self.on_update_settings_clicked(None)
 
     def on_container_changed(self, combo):
         ndx = combo.get_active()
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
index e1e2d73..f5c36e9 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
@@ -28,13 +28,11 @@ __all__ = ["size_from_entry", "populate_mountpoint_store", "validate_label",
            "selectedRaidLevel", "raidLevelSelection",
            "defaultRaidLevel", "requiresRaidSelection", "defaultContainerRaidLevel",
            "containerRaidLevelsSupported", "raidLevelsSupported", "get_container_type_name",
-           "AddDialog", "ConfirmDeleteDialog", "DisksDialog", "ContainerDialog",
-           "HelpDialog"]
+           "AddDialog", "ConfirmDeleteDialog", "DisksDialog", "ContainerDialog"]
 
 import functools
 import re
 
-from pyanaconda.product import productName
 from pyanaconda.iutil import lowerASCII
 from pyanaconda.storage_utils import size_from_input
 from pyanaconda.ui.helpers import InputCheck
diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.py b/pyanaconda/ui/gui/spokes/lib/passphrase.py
index 685d711..064d0a5 100644
--- a/pyanaconda/ui/gui/spokes/lib/passphrase.py
+++ b/pyanaconda/ui/gui/spokes/lib/passphrase.py
@@ -111,7 +111,7 @@ class PassphraseDialog(GUIObject, GUIInputCheckHandler):
         try:
             strength = self._pwq.check(passphrase, None, None)
         except pwquality.PWQError as e:
-            self._pwq_error = e[1]
+            self._pwq_error = e.args[1]
 
         if strength < 50:
             val = 1
diff --git a/pyanaconda/ui/tui/simpleline/base.py b/pyanaconda/ui/tui/simpleline/base.py
index e2d88a6..6371b93 100644
--- a/pyanaconda/ui/tui/simpleline/base.py
+++ b/pyanaconda/ui/tui/simpleline/base.py
@@ -287,7 +287,7 @@ class App(object):
                 self._redraw = False
             except ExitMainLoop:
                 raise
-            except Exception:
+            except Exception:    # pylint: disable=broad-except
                 send_exception(self.queue, sys.exc_info())
                 return False
 
@@ -346,7 +346,7 @@ class App(object):
                     prompt = last_screen.prompt(self._screens[-1][1])
                 except ExitMainLoop:
                     raise
-                except Exception:
+                except Exception:    # pylint: disable=broad-except
                     send_exception(self.queue, sys.exc_info())
                     continue
 
@@ -403,7 +403,7 @@ class App(object):
                         handler(event, data)
                     except ExitMainLoop:
                         raise
-                    except Exception:
+                    except Exception:    # pylint: disable=broad-except
                         send_exception(self.queue, sys.exc_info())
 
     def raw_input(self, prompt, hidden=False):
@@ -441,7 +441,7 @@ class App(object):
                     return True
             except ExitMainLoop:
                 raise
-            except Exception:
+            except Exception:    # pylint: disable=broad-except
                 send_exception(self.queue, sys.exc_info())
                 return False
 
diff --git a/pyanaconda/ui/tui/spokes/langsupport.py b/pyanaconda/ui/tui/spokes/langsupport.py
index 9badce2..0b1e836 100644
--- a/pyanaconda/ui/tui/spokes/langsupport.py
+++ b/pyanaconda/ui/tui/spokes/langsupport.py
@@ -26,8 +26,6 @@ from pyanaconda.ui.common import FirstbootSpokeMixIn
 from pyanaconda import localization
 from pyanaconda.i18n import N_, _
 
-from pyanaconda import flags
-
 class LangSpoke(FirstbootSpokeMixIn, NormalTUISpoke):
     """
     This spoke allows a user to select their installed language. Note that this
diff --git a/pyanaconda/ui/tui/spokes/source.py b/pyanaconda/ui/tui/spokes/source.py
index dd95d72..9795540 100644
--- a/pyanaconda/ui/tui/spokes/source.py
+++ b/pyanaconda/ui/tui/spokes/source.py
@@ -54,7 +54,7 @@ class SourceSpoke(EditTUISpoke, SourceSwitchHandler):
     title = N_("Installation source")
     category = SoftwareCategory
 
-    _protocols = ("http://", "https://", "ftp://", "nfs", N_("Closest mirror"))
+    _protocols = ["http://", "https://", "ftp://", "nfs", N_("Closest mirror")]
 
     # default to 'closest mirror', as done in the GUI
     _selection = 1
@@ -66,6 +66,8 @@ class SourceSpoke(EditTUISpoke, SourceSwitchHandler):
         self._error = False
         self._cdrom = None
 
+        self.errors = []
+
     def initialize(self):
         EditTUISpoke.initialize(self)
 
diff --git a/pyanaconda/ui/tui/spokes/user.py b/pyanaconda/ui/tui/spokes/user.py
index 7ef5b5d..029b939 100644
--- a/pyanaconda/ui/tui/spokes/user.py
+++ b/pyanaconda/ui/tui/spokes/user.py
@@ -130,7 +130,7 @@ class UserSpoke(FirstbootSpokeMixIn, EditTUISpoke):
         if self.args.gecos and not self.args.name:
             username = guess_username(self.args.gecos)
             if not USERNAME_VALID.match(username):
-                self.errors.append(_("Invalid user name: %s.\n" % username))
+                self.errors.append(_("Invalid user name: %s.\n") % username)
             else:
                 self.args.name = guess_username(self.args.gecos)
 
diff --git a/pyanaconda/ui/tui/tuiobject.py b/pyanaconda/ui/tui/tuiobject.py
index 0a5243f..855537f 100644
--- a/pyanaconda/ui/tui/tuiobject.py
+++ b/pyanaconda/ui/tui/tuiobject.py
@@ -116,15 +116,6 @@ class TUIObject(tui.UIScreen, common.UIObject):
     def showable(self):
         return True
 
-    def teardown(self):
-        pass
-
-    def initialize(self):
-        """This method gets called whenever Hub or UserInterface prepares
-        all found objects for use. It is called only once and has no direct
-        connection to rendering."""
-        pass
-
     def refresh(self, args = None):
         """Put everything to display into self.window list."""
         tui.UIScreen.refresh(self, args)
diff --git a/pyanaconda/users.py b/pyanaconda/users.py
index 232f243..d7e90a7 100644
--- a/pyanaconda/users.py
+++ b/pyanaconda/users.py
@@ -164,7 +164,7 @@ def validatePassword(pw, user="root", settings=None):
             # Leave valid alone here: the password is weak but can still
             # be accepted.
             # PWQError values are built as a tuple of (int, str)
-            message = e[1]
+            message = e.args[1]
 
     return (valid, strength, message)
 
diff --git a/tests/pyanaconda_tests/localization_test.py b/tests/pyanaconda_tests/localization_test.py
index 521fb4a..34672b2 100644
--- a/tests/pyanaconda_tests/localization_test.py
+++ b/tests/pyanaconda_tests/localization_test.py
@@ -153,6 +153,6 @@ class LangcodeLocaleMatchingTests(unittest.TestCase):
                 # cannot set locale (a bug in the locale module?)
                 continue
 
-            (order, formats) = localization.resolve_date_format(1, 2, 3, fail_safe=False)
+            order = localization.resolve_date_format(1, 2, 3, fail_safe=False)[0]
             for i in (1, 2, 3):
                 self.assertIn(i, order)
diff --git a/tests/pylint/pylint-false-positives b/tests/pylint/pylint-false-positives
index 8eb467a..9ccd8e9 100644
--- a/tests/pylint/pylint-false-positives
+++ b/tests/pylint/pylint-false-positives
@@ -4,6 +4,7 @@
 ^E0611:[ 0-9]*,[0-9]*:.*: No name '_isys' in module 'pyanaconda'$
 ^E0712:[ 0-9]*,[0-9]*:.*: Catching an exception which doesn't inherit from BaseException: GError$
 ^E0712:[ 0-9]*,[0-9]*:.*: Catching an exception which doesn't inherit from BaseException: S390Error$
+^E1120:[ 0-9]*,[0-9]*:.*: No value for argument 'self' in unbound method call$
 PyGIDeprecationWarning: GLib\..* is deprecated
 PyGIDeprecationWarning: GObject\..* is deprecated
 obj = getattr\(parent, name\)$
-- 
2.2.2



More information about the anaconda-patches mailing list