diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2022-04-13 13:30:50 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2022-04-13 15:01:30 +0200 |
commit | a10ff70f29fa03b465852c98d5a90155730052c5 (patch) | |
tree | aa4fcd5108cd8a86de151f1db2747846999b7d68 | |
parent | d2f23c771a53ff8bfc4909fc1318e68ebbb032ee (diff) | |
download | pylint-git-a10ff70f29fa03b465852c98d5a90155730052c5.tar.gz |
Add an __eq__ function to assert equality between MessageDefinition
-rw-r--r-- | pylint/message/message_definition.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pylint/message/message_definition.py b/pylint/message/message_definition.py index a729e595c..f19dcd1b7 100644 --- a/pylint/message/message_definition.py +++ b/pylint/message/message_definition.py @@ -3,7 +3,7 @@ # Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt import sys -from typing import TYPE_CHECKING, List, Optional, Tuple +from typing import TYPE_CHECKING, Any, List, Optional, Tuple from astroid import nodes @@ -52,6 +52,13 @@ class MessageDefinition: if msgid[0] not in MSG_TYPES: raise InvalidMessageError(f"Bad message type {msgid[0]} in {msgid!r}") + def __eq__(self, other: Any) -> bool: + return ( + isinstance(other, MessageDefinition) + and self.msgid == other.msgid + and self.symbol == other.symbol + ) + def __repr__(self) -> str: return f"MessageDefinition:{self.symbol} ({self.msgid})" |