Browse Source

Disable the remaining pylint warnings locally and enable pylint warnings in PRESUBMIT.

This causes some code clutter.

TEST=Increased pylint warning level
BUG=none

Review URL: http://codereview.chromium.org/4321006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@64913 0039d316-1c4b-4281-b951-d872f2087c98
maruel@chromium.org 15 years ago
parent
commit
b17b55beca
8 changed files with 41 additions and 9 deletions
  1. 6 6
      PRESUBMIT.py
  2. 2 0
      breakpad.py
  3. 2 0
      gcl.py
  4. 4 0
      gclient.py
  5. 6 0
      gclient_utils.py
  6. 2 0
      presubmit_canned_checks.py
  7. 14 2
      presubmit_support.py
  8. 5 1
      pylintrc

+ 6 - 6
PRESUBMIT.py

@@ -57,17 +57,17 @@ def RunPylint(input_api, output_api):
   # It uses non-standard pylint exceptions that makes pylint always fail.
   # It uses non-standard pylint exceptions that makes pylint always fail.
   files.remove('cpplint.py')
   files.remove('cpplint.py')
   try:
   try:
-    proc = input_api.subprocess.Popen(['pylint', '-E'] + sorted(files))
+    proc = input_api.subprocess.Popen(['pylint'] + sorted(files))
     proc.communicate()
     proc.communicate()
     if proc.returncode:
     if proc.returncode:
       return [output_api.PresubmitError('Fix pylint errors first.')]
       return [output_api.PresubmitError('Fix pylint errors first.')]
     return []
     return []
-  except OSError, e:
+  except OSError:
     if input_api.platform == 'win32':
     if input_api.platform == 'win32':
-        return [output_api.PresubmitNotifyResult(
-          'Warning: Can\'t run pylint because it is not installed. Please '
-          'install manually\n'
-          'Cannot do static analysis of python files.')]
+      return [output_api.PresubmitNotifyResult(
+        'Warning: Can\'t run pylint because it is not installed. Please '
+        'install manually\n'
+        'Cannot do static analysis of python files.')]
     return [output_api.PresubmitError(
     return [output_api.PresubmitError(
         'Please install pylint with "sudo apt-get install python-setuptools; '
         'Please install pylint with "sudo apt-get install python-setuptools; '
         'sudo easy_install pylint"\n'
         'sudo easy_install pylint"\n'

+ 2 - 0
breakpad.py

@@ -41,6 +41,8 @@ def SendStack(last_tb, stack, url=None):
         'host': socket.getfqdn(),
         'host': socket.getfqdn(),
         'cwd': os.getcwd(),
         'cwd': os.getcwd(),
     }
     }
+    # No exception type(s) specified
+    # pylint: disable=W0702
     try:
     try:
       # That may not always work.
       # That may not always work.
       params['exception'] = str(last_tb)
       params['exception'] = str(last_tb)

+ 2 - 0
gcl.py

@@ -1129,6 +1129,8 @@ def CMDlint(change_info, args):
   if not black_list:
   if not black_list:
     black_list = DEFAULT_LINT_IGNORE_REGEX
     black_list = DEFAULT_LINT_IGNORE_REGEX
   black_regex = re.compile(black_list)
   black_regex = re.compile(black_list)
+  # Access to a protected member _XX of a client class
+  # pylint: disable=W0212
   for filename in filenames:
   for filename in filenames:
     if white_regex.match(filename):
     if white_regex.match(filename):
       if black_regex.match(filename):
       if black_regex.match(filename):

+ 4 - 0
gclient.py

@@ -332,6 +332,8 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
           None, should_process))
           None, should_process))
     logging.debug('Loaded: %s' % str(self))
     logging.debug('Loaded: %s' % str(self))
 
 
+  # Arguments number differs from overridden method
+  # pylint: disable=W0221
   def run(self, revision_overrides, command, args, work_queue, options):
   def run(self, revision_overrides, command, args, work_queue, options):
     """Runs 'command' before parsing the DEPS in case it's a initial checkout
     """Runs 'command' before parsing the DEPS in case it's a initial checkout
     or a revert."""
     or a revert."""
@@ -1190,6 +1192,8 @@ def Main(argv):
     # Make stdout annotated with the thread ids.
     # Make stdout annotated with the thread ids.
     sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout)
     sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout)
     # Do it late so all commands are listed.
     # Do it late so all commands are listed.
+    # Unused variable 'usage'
+    # pylint: disable=W0612
     CMDhelp.usage = ('\n\nCommands are:\n' + '\n'.join([
     CMDhelp.usage = ('\n\nCommands are:\n' + '\n'.join([
         '  %-10s %s' % (fn[3:], Command(fn[3:]).__doc__.split('\n')[0].strip())
         '  %-10s %s' % (fn[3:], Command(fn[3:]).__doc__.split('\n')[0].strip())
         for fn in dir(sys.modules[__name__]) if fn.startswith('CMD')]))
         for fn in dir(sys.modules[__name__]) if fn.startswith('CMD')]))

+ 6 - 0
gclient_utils.py

@@ -316,6 +316,8 @@ def MakeFileAutoFlush(fileobj, delay=10):
     fileobj.delay = delay
     fileobj.delay = delay
     return fileobj
     return fileobj
 
 
+  # Attribute 'XXX' defined outside __init__
+  # pylint: disable=W0201
   new_fileobj = SoftClone(fileobj)
   new_fileobj = SoftClone(fileobj)
   if not hasattr(new_fileobj, 'lock'):
   if not hasattr(new_fileobj, 'lock'):
     new_fileobj.lock = threading.Lock()
     new_fileobj.lock = threading.Lock()
@@ -350,6 +352,8 @@ def MakeFileAnnotated(fileobj):
     # Already patched.
     # Already patched.
     return fileobj
     return fileobj
 
 
+  # Attribute 'XXX' defined outside __init__
+  # pylint: disable=W0201
   new_fileobj = SoftClone(fileobj)
   new_fileobj = SoftClone(fileobj)
   if not hasattr(new_fileobj, 'lock'):
   if not hasattr(new_fileobj, 'lock'):
     new_fileobj.lock = threading.Lock()
     new_fileobj.lock = threading.Lock()
@@ -698,6 +702,8 @@ class ExecutionQueue(object):
       """Runs in its own thread."""
       """Runs in its own thread."""
       logging.debug('running(%s)' % self.item.name)
       logging.debug('running(%s)' % self.item.name)
       work_queue = self.kwargs['work_queue']
       work_queue = self.kwargs['work_queue']
+      # It's necessary to catch all exceptions.
+      # pylint: disable=W0703
       try:
       try:
         self.item.run(*self.args, **self.kwargs)
         self.item.run(*self.args, **self.kwargs)
       except Exception:
       except Exception:

+ 2 - 0
presubmit_canned_checks.py

@@ -81,6 +81,8 @@ def CheckChangeLintsClean(input_api, output_api, source_file_filter=None):
 
 
   # Initialize cpplint.
   # Initialize cpplint.
   import cpplint
   import cpplint
+  # Access to a protected member _XX of a client class
+  # pylint: disable=W0212
   cpplint._cpplint_state.ResetErrorCounts()
   cpplint._cpplint_state.ResetErrorCounts()
 
 
   # Justifications for each filter:
   # Justifications for each filter:

+ 14 - 2
presubmit_support.py

@@ -41,6 +41,8 @@ except ImportError:
     import json
     import json
     # Some versions of python2.5 have an incomplete json module.  Check to make
     # Some versions of python2.5 have an incomplete json module.  Check to make
     # sure loads exists.
     # sure loads exists.
+    # Statement seems to have no effect
+    # pylint: disable=W0104
     json.loads
     json.loads
   except (ImportError, AttributeError):
   except (ImportError, AttributeError):
     # Import the one included in depot_tools.
     # Import the one included in depot_tools.
@@ -95,7 +97,8 @@ class OutputApi(object):
   """This class (more like a module) gets passed to presubmit scripts so that
   """This class (more like a module) gets passed to presubmit scripts so that
   they can specify various types of results.
   they can specify various types of results.
   """
   """
-
+  # Method could be a function
+  # pylint: disable=R0201
   class PresubmitResult(object):
   class PresubmitResult(object):
     """Base class for result objects."""
     """Base class for result objects."""
 
 
@@ -177,6 +180,8 @@ class InputApi(object):
   """An instance of this object is passed to presubmit scripts so they can
   """An instance of this object is passed to presubmit scripts so they can
   know stuff about the change they're looking at.
   know stuff about the change they're looking at.
   """
   """
+  # Method could be a function
+  # pylint: disable=R0201
 
 
   # File extensions that are considered source files from a style guide
   # File extensions that are considered source files from a style guide
   # perspective. Don't modify this list from a presubmit script!
   # perspective. Don't modify this list from a presubmit script!
@@ -392,7 +397,8 @@ class InputApi(object):
 
 
 class AffectedFile(object):
 class AffectedFile(object):
   """Representation of a file in a change."""
   """Representation of a file in a change."""
-
+  # Method could be a function
+  # pylint: disable=R0201
   def __init__(self, path, action, repository_root=''):
   def __init__(self, path, action, repository_root=''):
     self._path = path
     self._path = path
     self._action = action
     self._action = action
@@ -480,6 +486,8 @@ class AffectedFile(object):
 
 
 class SvnAffectedFile(AffectedFile):
 class SvnAffectedFile(AffectedFile):
   """Representation of a file in a change out of a Subversion checkout."""
   """Representation of a file in a change out of a Subversion checkout."""
+  # Method 'NNN' is abstract in class 'NNN' but is not overridden
+  # pylint: disable=W0223
 
 
   def __init__(self, *args, **kwargs):
   def __init__(self, *args, **kwargs):
     AffectedFile.__init__(self, *args, **kwargs)
     AffectedFile.__init__(self, *args, **kwargs)
@@ -526,6 +534,8 @@ class SvnAffectedFile(AffectedFile):
 
 
 class GitAffectedFile(AffectedFile):
 class GitAffectedFile(AffectedFile):
   """Representation of a file in a change out of a git checkout."""
   """Representation of a file in a change out of a git checkout."""
+  # Method 'NNN' is abstract in class 'NNN' but is not overridden
+  # pylint: disable=W0223
 
 
   def __init__(self, *args, **kwargs):
   def __init__(self, *args, **kwargs):
     AffectedFile.__init__(self, *args, **kwargs)
     AffectedFile.__init__(self, *args, **kwargs)
@@ -996,6 +1006,8 @@ def DoPresubmitChecks(change,
     if items:
     if items:
       output_stream.write('** Presubmit %s **\n' % name)
       output_stream.write('** Presubmit %s **\n' % name)
       for item in items:
       for item in items:
+        # Access to a protected member XXX of a client class
+        # pylint: disable=W0212
         if not item._Handle(output_stream, input_stream,
         if not item._Handle(output_stream, input_stream,
                             may_prompt=False):
                             may_prompt=False):
           error_count += 1
           error_count += 1

+ 5 - 1
pylintrc

@@ -36,6 +36,10 @@ load-plugins=
 # C0111: Missing docstring
 # C0111: Missing docstring
 # C0302: Too many lines in module (N)
 # C0302: Too many lines in module (N)
 # I0011: Locally disabling WNNNN
 # I0011: Locally disabling WNNNN
+#
+# It's a problem but not something we can fix right now.
+# R0401: Cyclic import
+#
 # R0801: Similar lines in N files
 # R0801: Similar lines in N files
 # R0901: Too many ancestors (8/7)
 # R0901: Too many ancestors (8/7)
 # R0902: Too many instance attributes (N/7)
 # R0902: Too many instance attributes (N/7)
@@ -53,7 +57,7 @@ load-plugins=
 # W0603: Using the global statement
 # W0603: Using the global statement
 # W0613: Unused argument ''
 # W0613: Unused argument ''
 # W6501: Specify string format arguments as logging function parameters
 # W6501: Specify string format arguments as logging function parameters
-disable=C0103,C0111,C0302,I0011,R0801,R0901,R0902,R0903,R0911,R0912,R0913,R0914,R0915,W0122,W0141,W0142,W0402,W0511,W0603,W0613,W6501
+disable=C0103,C0111,C0302,I0011,R0401,R0801,R0901,R0902,R0903,R0911,R0912,R0913,R0914,R0915,W0122,W0141,W0142,W0402,W0511,W0603,W0613,W6501
 
 
 
 
 [REPORTS]
 [REPORTS]