Skip to content

Commit 68938b6

Browse files
committed
Adding a fix for compatability with pylint 1.3. For 1.2 and previous, the messages were stored in the linter object, but since 1.3 have been stored in a separate dedicated MessageStore object. This commit adds some compatability checking to ensure both versions will work
1 parent 0009c94 commit 68938b6

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

pylint_plugin_utils/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,17 @@ def suppress_message(linter, checker_method, message_id_or_symbol, test_func):
9797
in one particular case, while leaving the rest of the messages intact.
9898
"""
9999
# At some point, pylint started preferring message symbols to message IDs. However this is not done
100-
# consistently or uniformly. We try to work around this here by suppressing both the ID and the symbol,
101-
# if we can find it.
100+
# consistently or uniformly - occasionally there are some message IDs with no matching symbols.
101+
# We try to work around this here by suppressing both the ID and the symbol, if we can find it.
102+
# This also gives us compatability with a broader range of pylint versions.
103+
104+
# Similarly, a commit between version 1.2 and 1.3 changed where the messages are stored - see:
105+
# https://bitbucket.org/logilab/pylint/commits/0b67f42799bed08aebb47babdc9fb0e761efc4ff#chg-reporters/__init__.py
106+
# Therefore here, we try the new attribute name, and fall back to the old version for
107+
# compatability with <=1.2 and >=1.3
108+
msgs_store = getattr(linter, 'msgs_store', linter)
102109
try:
103-
pylint_message = linter.check_message_id(message_id_or_symbol)
110+
pylint_message = msgs_store.check_message_id(message_id_or_symbol)
104111
symbols = [s for s in (pylint_message.msgid, pylint_message.symbol) if s is not None]
105112
except UnknownMessage:
106113
# This can happen due to mismatches of pylint versions and plugin expectations of available messages

0 commit comments

Comments
 (0)