Skip to content

Commit 08a62c8

Browse files
authored
Merge pull request #9 from federicobond/pylint2-fix
Fix compatibility with Pylint 2.0
2 parents b774efb + 66f14f6 commit 08a62c8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pylint_plugin_utils/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,16 @@ def suppress_message(linter, checker_method, message_id_or_symbol, test_func):
116116
# Therefore here, we try the new attribute name, and fall back to the old version for
117117
# compatability with <=1.2 and >=1.3
118118
msgs_store = getattr(linter, 'msgs_store', linter)
119+
120+
# pylint 2.0 renamed check_message_id to get_message_definition in:
121+
# https://github.com/PyCQA/pylint/commit/5ccbf9eaa54c0c302c9180bdfb745566c16e416d
122+
if hasattr(msgs_store, 'check_message_id'):
123+
get_message_definition = msgs_store.check_message_id
124+
else:
125+
get_message_definition = msgs_store.get_message_definition
126+
119127
try:
120-
pylint_message = msgs_store.check_message_id(message_id_or_symbol)
128+
pylint_message = get_message_definition(message_id_or_symbol)
121129
symbols = [s for s in (pylint_message.msgid, pylint_message.symbol) if s is not None]
122130
except UnknownMessage:
123131
# This can happen due to mismatches of pylint versions and plugin expectations of available messages

0 commit comments

Comments
 (0)