Skip to content

Commit 2813f18

Browse files
authored
Merge pull request #13 from shepilov-vladislav/master
[FIX] add support for pylint 2.3.0 (https://github.com/PyCQA/pylint/c…
2 parents 501bf29 + 6d86209 commit 2813f18

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

pylint_plugin_utils/__init__.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,26 @@ def suppress_message(linter, checker_method, message_id_or_symbol, test_func):
117117
# compatability with <=1.2 and >=1.3
118118
msgs_store = getattr(linter, 'msgs_store', linter)
119119

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
120+
def get_message_definitions(message_id_or_symbol):
121+
if hasattr(msgs_store, 'check_message_id'):
122+
return [msgs_store.check_message_id(message_id_or_symbol)]
123+
# pylint 2.0 renamed check_message_id to get_message_definition in:
124+
# https://github.com/PyCQA/pylint/commit/5ccbf9eaa54c0c302c9180bdfb745566c16e416d
125+
elif hasattr(msgs_store, 'get_message_definition'):
126+
return [msgs_store.get_message_definition(message_id_or_symbol)]
127+
# pylint 2.3.0 renamed get_message_definition to get_message_definitions in:
128+
# https://github.com/PyCQA/pylint/commit/da67a9da682e51844fbc674229ff6619eb9c816a
129+
elif hasattr(msgs_store, 'get_message_definitions'):
130+
return msgs_store.get_message_definitions(message_id_or_symbol)
131+
else:
132+
raise ValueError('pylint.utils.MessagesStore does not have a get_message_definition(s) method')
126133

127134
try:
128-
pylint_message = get_message_definition(message_id_or_symbol)
129-
symbols = [s for s in (pylint_message.msgid, pylint_message.symbol) if s is not None]
135+
pylint_messages = get_message_definitions(message_id_or_symbol)
136+
symbols = [symbol
137+
for pylint_message in pylint_messages
138+
for symbol in (pylint_message.msgid, pylint_message.symbol)
139+
if symbol is not None]
130140
except UnknownMessage:
131141
# This can happen due to mismatches of pylint versions and plugin expectations of available messages
132142
symbols = [message_id_or_symbol]

0 commit comments

Comments
 (0)