diff options
author | Julien Cristau <julien.cristau@logilab.fr> | 2013-07-17 11:17:23 +0200 |
---|---|---|
committer | Julien Cristau <julien.cristau@logilab.fr> | 2013-07-17 11:17:23 +0200 |
commit | 4cb9a4d440a05a4378b35f3fe37b29bf75de97bf (patch) | |
tree | c7e9ef51395e028662c200a51d7a5306962f4aa1 /utils.py | |
parent | 45f88016f4b4f610bb6ab5ff7593c81a74590406 (diff) | |
download | pylint-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.py | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -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) |