Commits

Anonymous committed 26c57c0

lint fixes

  • Participants
  • Parent commits 6144a29

Comments (0)

Files changed (13)

File checkers/base.py

         """check the use of an assert statement on a tuple."""
         if node.fail is None and isinstance(node.test, astng.Tuple) and \
            len(node.test.elts) == 2:
-             self.add_message('W0199', line=node.fromlineno, node=node)
+            self.add_message('W0199', line=node.fromlineno, node=node)
 
     @check_messages('W0109')
     def visit_dict(self, node):
         """check duplicate key in dictionary"""
         keys = set()
-        for k, v in node.items:
+        for k, _ in node.items:
             if isinstance(k, astng.Const):
                 key = k.value
                 if key in keys:

File checkers/format.py

                 start_row, start_col)
 
     def process_non_raw_string_token(self, prefix, string_body, start_row,
-        start_col):
+                                     start_col):
         """check for bad escapes in a non-raw string.
 
         prefix: lowercase string of eg 'ur' string prefix markers.

File checkers/imports.py

             lines.append('%s %s' % (mod, files))
             sub_indent_str = '  '
         else:
-            lines.append('%s\-%s %s' % (indent_str, mod, files))
+            lines.append(r'%s\-%s %s' % (indent_str, mod, files))
             if i == len(nodes)-1:
                 sub_indent_str = '%s  ' % indent_str
             else:

File checkers/string_format.py

             if isinstance(args, astng.Dict):
                 keys = set()
                 unknown_keys = False
-                for k, v in args.items:
+                for k, _ in args.items:
                     if isinstance(k, astng.Const):
                         key = k.value
                         if isinstance(key, basestring):

File checkers/typecheck.py

                 continue
             except NotFoundError:
                 if isinstance(owner, astng.Function) and owner.decorators:
-                   continue
+                    continue
                 if isinstance(owner, Instance) and owner.has_dynamic_getattr():
                     continue
                 # explicit skipping of optparse'Values class
         for [(name, defval), assigned] in parameters:
             if (defval is None) and not assigned:
                 if name is None:
-                    display = '<tuple>'
+                    display_name = '<tuple>'
                 else:
                     display_name = repr(name)
                 self.add_message('E1120', node=node, args=display_name)

File checkers/variables.py

 
 
 def in_for_else_branch(parent, stmt):
-  """Returns True if stmt in inside the else branch for a parent For stmt."""
-  return (isinstance(parent, astng.For) and
-          any(else_stmt.parent_of(stmt) for else_stmt in parent.orelse))
+    """Returns True if stmt in inside the else branch for a parent For stmt."""
+    return (isinstance(parent, astng.For) and
+            any(else_stmt.parent_of(stmt) for else_stmt in parent.orelse))
 
 def overridden_method(klass, name):
     """get overridden method if any"""
           '(W)':'black', '(E)':'darkred',
           '(F)':'red'}
 
+
+def convert_to_string(msg):
+    """make a string representation of a message"""
+    if (msg[2] != ""):
+        return "(" + msg[0] + ") " + msg[1] + "." + msg[2] + " [" + msg[3] + "]: " + msg[4]
+    else:
+        return "(" + msg[0] + ") " + msg[1] + " [" + msg[3] + "]: " + msg[4]
+
 class BasicStream:
     '''
     used in gui reporter instead of writing to stdout, it is written to
 
         if text.startswith('\n'):
             self.contents.append('')
-            if self.currout: self.outdict[self.currout].append('')
+            if self.currout:
+                self.outdict[self.currout].append('')
         self.contents[-1] += text.strip('\n')
-        if self.currout: self.outdict[self.currout][-1] += text.strip('\n')
+        if self.currout:
+            self.outdict[self.currout][-1] += text.strip('\n')
         if text.endswith('\n') and text.strip():
             self.contents.append('')
-            if self.currout: self.outdict[self.currout].append('')
+            if self.currout:
+                self.outdict[self.currout].append('')
 
     def fix_contents(self):
         """finalize what the contents of the dict should look like before output"""
         for item in self.outdict:
             numEmpty = self.outdict[item].count('')
-            for i in range(numEmpty):
+            for i in xrange(numEmpty):
                 self.outdict[item].remove('')
             if self.outdict[item]:
                 self.outdict[item].pop(0)
         self.lbMessages.delete(0, END)
         for msg in self.msgs:
             if (self.msg_type_dict.get(msg[0])()):
-                msg_str = self.convert_to_string(msg)
+                msg_str = convert_to_string(msg)
                 self.lbMessages.insert(END, msg_str)
                 fg_color = COLORS.get(msg_str[:3], 'black')
                 self.lbMessages.itemconfigure(END, fg=fg_color)
         except:
             pass
 
-    def convert_to_string(self, msg):
-        """make a string representation of a message"""
-        if (msg[2] != ""):
-            return "(" + msg[0] + ") " + msg[1] + "." + msg[2] + " [" + msg[3] + "]: " + msg[4]
-        else:
-            return "(" + msg[0] + ") " + msg[1] + " [" + msg[3] + "]: " + msg[4]
-
     def process_incoming(self):
         """process the incoming messages from running pylint"""
         while self.msg_queue.qsize():
 
                 #displaying msg if message type is selected in check box
                 if (self.msg_type_dict.get(msg[0])()):
-                    msg_str = self.convert_to_string(msg)
+                    msg_str = convert_to_string(msg)
                     self.lbMessages.insert(END, msg_str)
                     fg_color = COLORS.get(msg_str[:3], 'black')
                     self.lbMessages.itemconfigure(END, fg=fg_color)
 def lint_thread(module, reporter, gui):
     """thread for pylint"""
     gui.status.text = "processing module(s)"
-    lint_obj = pylint.lint.Run(args=[module], reporter=reporter, exit=False)
+    pylint.lint.Run(args=[module], reporter=reporter, exit=False)
     gui.msg_queue.put("DONE")
 
 

File interfaces.py

         """
 
 
-__all__ = ('IRawChecker', 'IStatable', 'ILinter', 'IReporter')
+__all__ = ('IRawChecker', 'ILinter', 'IReporter')
 from logilab.astng import MANAGER, nodes, ASTNGBuildingException
 from logilab.astng.__pkginfo__ import version as astng_version
 
-from pylint.utils import PyLintASTWalker, UnknownMessage, MessagesHandlerMixIn,\
-     ReportsHandlerMixIn, MSG_TYPES, expand_modules
+from pylint.utils import (PyLintASTWalker, UnknownMessage, MessagesHandlerMixIn,
+                          ReportsHandlerMixIn, MSG_TYPES, expand_modules)
 from pylint.interfaces import ILinter, IRawChecker, IASTNGChecker
-from pylint.checkers import BaseRawChecker, EmptyReport, \
-     table_lines_from_stats
-from pylint.reporters.text import TextReporter, ParseableTextReporter, \
-     VSTextReporter, ColorizedTextReporter
+from pylint.checkers import (BaseRawChecker, EmptyReport,
+                             table_lines_from_stats)
+from pylint.reporters.text import (TextReporter, ParseableTextReporter,
+                                   VSTextReporter, ColorizedTextReporter)
 from pylint.reporters.html import HTMLReporter
 from pylint import config
 
 from pylint.__pkginfo__ import version
 
 
-OPTION_RGX = re.compile('\s*#*\s*pylint:(.*)')
+OPTION_RGX = re.compile(r'\s*#*\s*pylint:(.*)')
 REPORTER_OPT_MAP = {'text': TextReporter,
                     'parseable': ParseableTextReporter,
                     'msvs': VSTextReporter,

File reporters/text.py

             path = path.replace(self._prefix, '')
         self.writeln(self.line_format % locals())
 
+
 class VSTextReporter(ParseableTextReporter):
     """Visual studio text reporter"""
     line_format = '%(path)s(%(line)s): [%(sigle)s%(obj)s] %(msg)s'

File test/utils.py

 """some pylint test utilities
 """
 
-# # # # #  pyreverse unittest utilities  # # # # # #
-
-from logilab.common.testlib import TestCase
 import os
 import sys
 from os.path import join, dirname, abspath
 
+from logilab.common.testlib import TestCase
 from logilab.astng import MANAGER
 
 
-
 def _astng_wrapper(func, modname):
     return func(modname)
 

File testutils.py

-# Copyright (c) 2003-2008 LOGILAB S.A. (Paris, FRANCE).
+# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
 # http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This program is free software; you can redistribute it and/or modify it under
 # 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 """functional/non regression tests for pylint"""
 
-import unittest
 import sys
 import re
 
 from glob import glob
 from os import linesep
-from os.path import exists, abspath, dirname, join, basename, splitext
+from os.path import abspath, dirname, join, basename, splitext
 from cStringIO import StringIO
 
 from logilab.common import testlib
 
-from logilab.astng import MANAGER
+from pylint import checkers
 from pylint.reporters import BaseReporter
 from pylint.interfaces import IReporter
 from pylint.lint import PyLinter
-from pylint import checkers
 
 
 # Utils
         result.append((infile, outfile))
     return result
 
+
 class TestReporter(BaseReporter):
-    """ store plain text messages
-    """
+    """reporter storing plain text messages"""
 
     __implements____ = IReporter
 
     def finalize(self):
         self.messages.sort()
         for msg in self.messages:
-            print >>self.out, msg
+            print >> self.out, msg
         result = self.out.getvalue()
         self.reset()
         return result
 # Test classes
 
 class LintTestUsingModule(testlib.TestCase):
+    INPUT_DIR = None
     DEFAULT_PACKAGE = 'input'
     package = DEFAULT_PACKAGE
     linter = linter
     module = None
     depends = None
-
+    output = None
     _TEST_TYPE = 'module'
 
     def shortDescription(self):
 
 import sys
 from warnings import warn
-from os import linesep
 from os.path import dirname, basename, splitext, exists, isdir, join, normpath
 
 from logilab.common.modutils import modpath_from_file, get_module_files, \
         # msgid is a category?
         catid = category_id(msgid)
         if catid is not None:
-            for msgid in self._msgs_by_category.get(catid):
-                self.disable(msgid, scope, line)
+            for _msgid in self._msgs_by_category.get(catid):
+                self.disable(_msgid, scope, line)
             return
         # msgid is a checker name?
         if msgid.lower() in self._checkers:
             for checker in self._checkers[msgid.lower()]:
-                for msgid in checker.msgs:
-                    self.disable(msgid, scope, line)
+                for _msgid in checker.msgs:
+                    self.disable(_msgid, scope, line)
             return
         # msgid is report id?
         if msgid.lower().startswith('rp'):