a few pylint fixes and copyright cleanups

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changeset9a48c3ce5e5e
branchdefault
phasepublic
hiddenno
parent revision#962fff72742b Emit a warning for loops that have an else clause but no break or return.
child revision#b87851e4b8ff fix NameError
files modified by this revision
checkers/base.py
lint.py
reporters/text.py
testutils.py
utils.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1364578941 -3600
# Fri Mar 29 18:42:21 2013 +0100
# Node ID 9a48c3ce5e5e702800aba861c5ee8ed75af54961
# Parent 962fff72742b39048be2ec50648cd432fd3fded7
a few pylint fixes and copyright cleanups

diff --git a/checkers/base.py b/checkers/base.py
@@ -1,6 +1,6 @@
1 -# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
2 +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
3  # Copyright (c) 2009-2010 Arista Networks, Inc.
4  # http://www.logilab.fr/ -- mailto:contact@logilab.fr
5  # This program is free software; you can redistribute it and/or modify it under
6  # the terms of the GNU General Public License as published by the Free Software
7  # Foundation; either version 2 of the License, or (at your option) any later
diff --git a/lint.py b/lint.py
@@ -1,7 +1,6 @@
8 -# Copyright (c) 2003-2010 Sylvain Thenault (thenault@gmail.com).
9 -# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
10 +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
11  # http://www.logilab.fr/ -- mailto:contact@logilab.fr
12  #
13  # This program is free software; you can redistribute it and/or modify it under
14  # the terms of the GNU General Public License as published by the Free Software
15  # Foundation; either version 2 of the License, or (at your option) any later
@@ -628,11 +627,10 @@
16          # XXX hack, to be correct we need to keep module_msgs_state
17          # for every analyzed module (the problem stands with localized
18          # messages which are only detected in the .close step)
19          if modname:
20              self._module_msgs_state = {}
21 -            self._module_msg_cats_state = {}
22              self._raw_module_msgs_state = {}
23              self._ignored_msgs = {}
24 
25      def get_astng(self, filepath, modname):
26          """return a astng representation for a module"""
@@ -860,12 +858,12 @@
27              preprocess_options(args, {
28                  # option: (callback, takearg)
29                  'rcfile':       (self.cb_set_rcfile, True),
30                  'load-plugins': (self.cb_add_plugins, True),
31                  })
32 -        except ArgumentPreprocessingError, e:
33 -            print >> sys.stderr, 'Argument %s expects a value.' % (e.args[0],)
34 +        except ArgumentPreprocessingError, ex:
35 +            print >> sys.stderr, 'Argument %s expects a value.' % (ex.args[0],)
36              sys.exit(32)
37 
38          self.linter = linter = self.LinterClass((
39              ('rcfile',
40               {'action' : 'callback', 'callback' : lambda *args: 1,
diff --git a/reporters/text.py b/reporters/text.py
@@ -1,7 +1,6 @@
41 -# Copyright (c) 2003-2007 Sylvain Thenault (thenault@gmail.com).
42 -# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
43 +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
44  # This program is free software; you can redistribute it and/or modify it under
45  # the terms of the GNU General Public License as published by the Free Software
46  # Foundation; either version 2 of the License, or (at your option) any later
47  # version.
48  #
@@ -21,11 +20,10 @@
49  :colorized: an ANSI colorized text reporter
50 
51  """
52 
53  import os
54 -import sys
55 
56  from logilab.common.ureports import TextWriter
57  from logilab.common.textutils import colorize_ansi
58 
59  from pylint.interfaces import IReporter
diff --git a/testutils.py b/testutils.py
@@ -1,6 +1,6 @@
60 -# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
61 +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
62  # http://www.logilab.fr/ -- mailto:contact@logilab.fr
63  #
64  # This program is free software; you can redistribute it and/or modify it under
65  # the terms of the GNU General Public License as published by the Free Software
66  # Foundation; either version 2 of the License, or (at your option) any later
@@ -90,14 +90,14 @@
67          self.out = StringIO()
68          self.messages = []
69 
70      def add_message(self, msg_id, location, msg):
71          """manage message of different type and in the context of path """
72 -        fpath, module, object, line, _ = location
73 +        fpath, module, obj, line, _ = location
74          self.message_ids[msg_id] = 1
75          if object:
76 -            object = ':%s' % object
77 +            object = ':%s' % obj
78          sigle = msg_id[0]
79          self.messages.append('%s:%3s%s: %s' % (sigle, line, object, msg))
80 
81      def finalize(self):
82          self.messages.sort()
@@ -125,11 +125,11 @@
83          return LINE_RGX.sub('\n', string)
84  else:
85      def ulines(string):
86          return string
87 
88 -INFO_TEST_RGX = re.compile('^func_i\d\d\d\d$')
89 +INFO_TEST_RGX = re.compile(r'^func_i\d\d\d\d$')
90 
91  def exception_str(self, ex):
92      """function used to replace default __str__ method of exception instances"""
93      return 'in %s\n:: %s' % (ex.file, ', '.join(ex.args))
94 
diff --git a/utils.py b/utils.py
@@ -1,7 +1,6 @@
95 -# Copyright (c) 2003-2010 Sylvain Thenault (thenault@gmail.com).
96 -# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
97 +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
98  # http://www.logilab.fr/ -- mailto:contact@logilab.fr
99  #
100  # This program is free software; you can redistribute it and/or modify it under
101  # the terms of the GNU General Public License as published by the Free Software
102  # Foundation; either version 2 of the License, or (at your option) any later
@@ -131,10 +130,11 @@
103          self._module_msgs_state = {} # None
104          self._raw_module_msgs_state = {}
105          self._msgs_by_category = {}
106          self.msg_status = 0
107          self._ignored_msgs = {}
108 +        self._suppression_mapping = {}
109 
110      def register_messages(self, checker):
111          """register a dictionary of messages
112 
113          Keys are message ids, values are a 2-uple with the message type and the
@@ -154,11 +154,11 @@
114              if len(msg_tuple) > 2:
115                  (msg, msgsymbol, msgdescr) = msg_tuple[:3]
116                  assert msgsymbol not in self._messages_by_symbol, \
117                      'Message symbol %r is already defined' % msgsymbol
118                  if len(msg_tuple) > 3 and 'scope' in msg_tuple[3]:
119 -                  scope = msg_tuple[3]['scope']
120 +                    scope = msg_tuple[3]['scope']
121              else:
122                  # messages should have a symbol, but for backward compatibility
123                  # they may not.
124                  (msg, msgdescr) = msg_tuple
125                  warn("[pylint 0.26] description of message %s doesn't include "