summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorJulien Cristau <julien.cristau@logilab.fr>2013-07-17 11:17:23 +0200
committerJulien Cristau <julien.cristau@logilab.fr>2013-07-17 11:17:23 +0200
commit4cb9a4d440a05a4378b35f3fe37b29bf75de97bf (patch)
treec7e9ef51395e028662c200a51d7a5306962f4aa1 /utils.py
parent45f88016f4b4f610bb6ab5ff7593c81a74590406 (diff)
downloadpylint-4cb9a4d440a05a4378b35f3fe37b29bf75de97bf.tar.gz
utils: allow specifying min and max relevant python versions for a message
Some messages don't make sense for all python versions. Allow that information to be recorded in the message declaration.
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/utils.py b/utils.py
index b898ab6..ce3450e 100644
--- a/utils.py
+++ b/utils.py
@@ -174,8 +174,19 @@ class MessagesHandlerMixIn(object):
(msg, msgsymbol, msgdescr) = msg_tuple[:3]
assert msgsymbol not in self._messages_by_symbol, \
'Message symbol %r is already defined' % msgsymbol
- if len(msg_tuple) > 3 and 'scope' in msg_tuple[3]:
- scope = msg_tuple[3]['scope']
+ if len(msg_tuple) > 3:
+ if 'scope' in msg_tuple[3]:
+ scope = msg_tuple[3]['scope']
+ if 'minversion' in msg_tuple[3]:
+ minversion = msg_tuple[3]['minversion']
+ if minversion > sys.version_info:
+ self._msgs_state[msgid] = False
+ continue
+ if 'maxversion' in msg_tuple[3]:
+ maxversion = msg_tuple[3]['maxversion']
+ if maxversion <= sys.version_info:
+ self._msgs_state[msgid] = False
+ continue
else:
# messages should have a symbol, but for backward compatibility
# they may not.
@@ -229,7 +240,8 @@ class MessagesHandlerMixIn(object):
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
- self.disable(_msgid, scope, line)
+ if _msgid in self._messages:
+ self.disable(_msgid, scope, line)
return
# msgid is report id?
if msgid.lower().startswith('rp'):
@@ -474,9 +486,8 @@ class MessagesHandlerMixIn(object):
def list_messages(self):
"""output full messages list documentation in ReST format"""
msgids = []
- for checker in self.get_checkers():
- for msgid in checker.msgs.iterkeys():
- msgids.append(msgid)
+ for msgid in self._messages:
+ msgids.append(msgid)
msgids.sort()
for msgid in msgids:
print self.get_message_help(msgid, False)