Add targetted pylint disables
authorIustin Pop <iustin@google.com>
Mon, 21 Dec 2009 15:12:43 +0000 (16:12 +0100)
committerIustin Pop <iustin@google.com>
Mon, 28 Dec 2009 10:43:16 +0000 (11:43 +0100)
This patch adds targeted pylint disables, where it makes sense (either
due to limitations in pylint or due to historical usage), and also a few
blanket ones in rapi where all the names are… “different”.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Olivier Tharan <olive@google.com>

15 files changed:
lib/__init__.py
lib/backend.py
lib/bdev.py
lib/cli.py
lib/cmdlib.py
lib/http/client.py
lib/jstore.py
lib/locking.py
lib/mcpu.py
lib/objects.py
lib/rapi/baserlib.py
lib/rapi/connector.py
lib/rapi/rlib2.py
lib/rpc.py
lib/serializer.py

index bab6818..b7fb973 100644 (file)
@@ -20,3 +20,5 @@
 
 
 # empty file for package definition
+
+"""Ganeti python modules"""
index 30984b3..588413f 100644 (file)
@@ -1151,6 +1151,7 @@ def BlockdevCreate(disk, size, owner, on_primary, info):
         # we need the children open in case the device itself has to
         # be assembled
         try:
+          # pylint: disable-msg=E1103
           crdev.Open()
         except errors.BlockDeviceError, err:
           errmsg = "Can't make child '%s' read-write: %s" % (child, err)
@@ -1297,6 +1298,7 @@ def BlockdevAssemble(disk, owner, as_primary):
   try:
     result = _RecursiveAssembleBD(disk, owner, as_primary)
     if isinstance(result, bdev.BlockDev):
+      # pylint: disable-msg=E1103
       result = result.dev_path
   except errors.BlockDeviceError, err:
     result = "Error while assembling disk: %s" % str(err)
@@ -2510,7 +2512,9 @@ class HooksRunner(object):
     """
     if hooks_base_dir is None:
       hooks_base_dir = constants.HOOKS_BASE_DIR
-    self._BASE_DIR = hooks_base_dir
+    # yeah, _BASE_DIR is not valid for attributes, we use it like a
+    # constant
+    self._BASE_DIR = hooks_base_dir # pylint: disable-msg=C0103
 
   @staticmethod
   def ExecHook(script, env):
index 131fbcf..e3a067c 100644 (file)
@@ -720,7 +720,7 @@ class DRBD8Status(object):
       self.est_time = None
 
 
-class BaseDRBD(BlockDev):
+class BaseDRBD(BlockDev): # pylint: disable-msg=W0223
   """Base DRBD class.
 
   This class contains a few bits of common functionality between the
index 95f3cc9..2185dfb 100644 (file)
@@ -198,12 +198,12 @@ SYNC_OPT = make_option("--sync", dest="do_locking",
                        " in order to ensure more consistent results")
 
 
-def ARGS_FIXED(val):
+def ARGS_FIXED(val): # pylint: disable-msg=C0103
   """Macro-like function denoting a fixed number of arguments"""
   return -val
 
 
-def ARGS_ATLEAST(val):
+def ARGS_ATLEAST(val): # pylint: disable-msg=C0103
   """Macro-like function denoting a minimum number of arguments"""
   return val
 
@@ -797,8 +797,8 @@ def GenerateTable(headers, fields, separator, data,
   if unitfields is None:
     unitfields = []
 
-  numfields = utils.FieldSet(*numfields)
-  unitfields = utils.FieldSet(*unitfields)
+  numfields = utils.FieldSet(*numfields)   # pylint: disable-msg=W0142
+  unitfields = utils.FieldSet(*unitfields) # pylint: disable-msg=W0142
 
   format_fields = []
   for field in fields:
index 87ce76d..ed87967 100644 (file)
@@ -84,8 +84,8 @@ class LogicalUnit(object):
     self.recalculate_locks = {}
     self.__ssh = None
     # logging
-    self.LogWarning = processor.LogWarning
-    self.LogInfo = processor.LogInfo
+    self.LogWarning = processor.LogWarning # pylint: disable-msg=C0103
+    self.LogInfo = processor.LogInfo # pylint: disable-msg=C0103
 
     for attr_name in self._OP_REQP:
       attr_val = getattr(op, attr_name, None)
@@ -322,7 +322,7 @@ class LogicalUnit(object):
     del self.recalculate_locks[locking.LEVEL_NODE]
 
 
-class NoHooksLU(LogicalUnit):
+class NoHooksLU(LogicalUnit): # pylint: disable-msg=W0223
   """Simple LU which runs no hooks.
 
   This LU is intended as a parent for other LogicalUnits which will
@@ -6635,7 +6635,7 @@ class LURemoveExport(NoHooksLU):
                   " Domain Name.")
 
 
-class TagsLU(NoHooksLU):
+class TagsLU(NoHooksLU): # pylint: disable-msg=W0223
   """Generic tags LU.
 
   This is an abstract class which is the parent of all the other tags LUs.
index 717581f..766354a 100644 (file)
@@ -254,7 +254,7 @@ class HttpClientRequestExecutor(http.HttpBase):
 
     # Do the secret SSL handshake
     if self.using_ssl:
-      self.sock.set_connect_state()
+      self.sock.set_connect_state() # pylint: disable-msg=E1103
       try:
         http.Handshake(self.sock, self.WRITE_TIMEOUT)
       except http.HttpSessionHandshakeUnexpectedEOF:
index 5c59968..723cda1 100644 (file)
@@ -130,11 +130,12 @@ def InitAndVerifyQueue(must_lock):
 
       if serial is None:
         # There must be a serious problem
-        raise errors.JobQueueError("Can't read/parse the job queue serial file")
+        raise errors.JobQueueError("Can't read/parse the job queue"
+                                   " serial file")
 
       if not must_lock:
-        # There's no need for more error handling. Closing the lock file below in
-        # case of an error will unlock it anyway.
+        # There's no need for more error handling. Closing the lock
+        # file below in case of an error will unlock it anyway.
         queue_lock.Unlock()
 
   except:
index d24abdf..874b7c0 100644 (file)
@@ -753,7 +753,7 @@ class GanetiLockManager:
     # the test cases.
     return utils.any((self._is_owned(l) for l in LEVELS[level + 1:]))
 
-  def _BGL_owned(self):
+  def _BGL_owned(self): # pylint: disable-msg=C0103
     """Check if the current thread owns the BGL.
 
     Both an exclusive or a shared acquisition work.
@@ -761,7 +761,7 @@ class GanetiLockManager:
     """
     return BGL in self.__keyring[LEVEL_CLUSTER]._list_owned()
 
-  def _contains_BGL(self, level, names):
+  def _contains_BGL(self, level, names): # pylint: disable-msg=C0103
     """Check if the level contains the BGL.
 
     Check if acting on the given level and set of names will change
index 959a837..4a5dbd5 100644 (file)
@@ -100,7 +100,7 @@ class Processor(object):
     """
     self.context = context
     self._feedback_fn = None
-    self.exclusive_BGL = False
+    self.exclusive_BGL = False # pylint: disable-msg=C0103
     self.rpc = rpc.RpcRunner(context.cfg)
 
   def _ExecLU(self, lu):
index 43cea75..3952891 100644 (file)
@@ -786,6 +786,8 @@ class Cluster(TaggableObject):
     """Fill defaults for missing configuration values.
 
     """
+    # pylint: disable-msg=E0203
+    # because these are "defined" via slots, not manually
     if self.hvparams is None:
       self.hvparams = constants.HVC_DEFAULTS
     else:
index 77a7e62..3b195ed 100644 (file)
 
 """
 
+# pylint: disable-msg=C0103
+
+# C0103: Invalid name, since the R_* names are not conforming
+
 import logging
 
 from ganeti import luxi
index c6270ab..91ce12f 100644 (file)
 
 """
 
+# pylint: disable-msg=C0103
+
+# C0103: Invalid name, since the R_* names are not conforming
+
 import cgi
 import re
 
index 96671ec..f99959d 100644 (file)
 
 """
 
+# pylint: disable-msg=C0103
+
+# C0103: Invalid name, since the R_* names are not conforming
+
 from ganeti import opcodes
 from ganeti import http
 from ganeti import constants
@@ -30,7 +34,6 @@ from ganeti import cli
 from ganeti.rapi import baserlib
 
 
-
 I_FIELDS = ["name", "admin_state", "os",
             "pnode", "snodes",
             "disk_template",
index e138859..b1054ca 100644 (file)
@@ -42,7 +42,8 @@ from ganeti import serializer
 from ganeti import constants
 from ganeti import errors
 
-import ganeti.http.client
+# pylint has a bug here, doesn't see this import
+import ganeti.http.client  # pylint: disable-msg=W0611
 
 
 # Module level variable
@@ -55,7 +56,7 @@ def Init():
   Must be called before using any RPC function.
 
   """
-  global _http_manager
+  global _http_manager # pylint: disable-msg=W0603
 
   assert not _http_manager, "RPC module initialized more than once"
 
@@ -68,7 +69,7 @@ def Shutdown():
   Must be called before quitting the program.
 
   """
-  global _http_manager
+  global _http_manager # pylint: disable-msg=W0603
 
   if _http_manager:
     _http_manager.Shutdown()
index fcde992..a5a9ca4 100644 (file)
@@ -24,6 +24,10 @@ This module introduces a simple abstraction over the serialization
 backend (currently json).
 
 """
+# pylint: disable-msg=C0103
+
+# C0103: Invalid name, since pylint doesn't see that Dump points to a
+# function and not a constant
 
 import simplejson
 import re