summaryrefslogtreecommitdiff
path: root/pylint/utils.py
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2018-11-10 09:45:27 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2018-12-18 07:49:48 +0100
commit572f35f92e9eeffd7f6e48b6de1e3623848a39cc (patch)
tree453149c4090811a31f8fa86cac770e816f8b6858 /pylint/utils.py
parentbce332ab43b6d7cce30bc833d2d3d1e1cd6f1054 (diff)
downloadpylint-git-572f35f92e9eeffd7f6e48b6de1e3623848a39cc.tar.gz
Refactor - Made the error message predictable
When refactoring MsgStore we don't want the test to break if two conflicting symbol or msgid are inverted. So we sort them, in order for the error message to stay stable.
Diffstat (limited to 'pylint/utils.py')
-rw-r--r--pylint/utils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pylint/utils.py b/pylint/utils.py
index 9119d1713..506dbf0ca 100644
--- a/pylint/utils.py
+++ b/pylint/utils.py
@@ -973,9 +973,11 @@ class MessagesStore:
:param str other_symbol: Other offending symbol
:raises InvalidMessageError: when a symbol is duplicated.
"""
+ symbols = [symbol, other_symbol]
+ symbols.sort()
error_message = "Message id '{msgid}' cannot have both ".format(msgid=msgid)
error_message += "'{other_symbol}' and '{symbol}' as symbolic name.".format(
- other_symbol=other_symbol, symbol=symbol
+ other_symbol=symbols[0], symbol=symbols[1]
)
raise InvalidMessageError(error_message)
@@ -988,11 +990,13 @@ class MessagesStore:
:param str other_msgid: Other offending msgid
:raises InvalidMessageError: when a msgid is duplicated.
"""
+ msgids = [msgid, other_msgid]
+ msgids.sort()
error_message = "Message symbol '{symbol}' cannot be used for ".format(
symbol=symbol
)
error_message += "'{other_msgid}' and '{msgid}' at the same time.".format(
- other_msgid=other_msgid, msgid=msgid
+ other_msgid=msgids[0], msgid=msgids[1]
)
raise InvalidMessageError(error_message)