From 341b470f60a26dbd4b72d27f3925930517da0744 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 8 Mar 2023 13:53:18 +0100 Subject: [PATCH 1/2] [deprecation] Remove get messages definitions in BaseChecker --- pylint/checkers/base_checker.py | 14 -------------- tests/checkers/unittest_base_checker.py | 11 ----------- 2 files changed, 25 deletions(-) diff --git a/pylint/checkers/base_checker.py b/pylint/checkers/base_checker.py index dd7a0222fc..fb921db1e9 100644 --- a/pylint/checkers/base_checker.py +++ b/pylint/checkers/base_checker.py @@ -234,20 +234,6 @@ def messages(self) -> list[MessageDefinition]: for msgid, msg_tuple in sorted(self.msgs.items()) ] - def get_message_definition(self, msgid: str) -> MessageDefinition: - # TODO: 3.0: Remove deprecated method - warnings.warn( - "'get_message_definition' is deprecated and will be removed in 3.0.", - DeprecationWarning, - stacklevel=2, - ) - for message_definition in self.messages: - if message_definition.msgid == msgid: - return message_definition - error_msg = f"MessageDefinition for '{msgid}' does not exists. " - error_msg += f"Choose from {[m.msgid for m in self.messages]}." - raise InvalidMessageError(error_msg) - def open(self) -> None: """Called before visiting project (i.e. set of modules).""" diff --git a/tests/checkers/unittest_base_checker.py b/tests/checkers/unittest_base_checker.py index 81a9c73d07..95013cc9b5 100644 --- a/tests/checkers/unittest_base_checker.py +++ b/tests/checkers/unittest_base_checker.py @@ -132,16 +132,5 @@ def test_base_checker_ordering() -> None: def test_base_checker_invalid_message() -> None: linter = PyLinter() - with pytest.raises(InvalidMessageError): linter.register_checker(MissingFieldsChecker(linter)) - - -def test_get_message_definition() -> None: - checker = LessBasicChecker() - with pytest.warns(DeprecationWarning): - with pytest.raises(InvalidMessageError): - checker.get_message_definition("W123") - - with pytest.warns(DeprecationWarning): - assert checker.get_message_definition("W0001") From 98f7de3efe8656dc7f09d353d40580881e72a9dd Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 8 Mar 2023 15:24:43 +0100 Subject: [PATCH 2/2] Changelog --- doc/whatsnew/fragments/8401.breaking | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 doc/whatsnew/fragments/8401.breaking diff --git a/doc/whatsnew/fragments/8401.breaking b/doc/whatsnew/fragments/8401.breaking new file mode 100644 index 0000000000..9f4f927401 --- /dev/null +++ b/doc/whatsnew/fragments/8401.breaking @@ -0,0 +1,4 @@ +``get_message_definition`` was removed from the base checker API. You can access +message definitions through the ``MessageStore``. + +Refs #8401