Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deprecation] Remove get_message_definitions from BaseChecker #8401

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/8401.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``get_message_definition`` was removed from the base checker API. You can access
message definitions through the ``MessageStore``.

Refs #8401
14 changes: 0 additions & 14 deletions pylint/checkers/base_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."""

Expand Down
11 changes: 0 additions & 11 deletions tests/checkers/unittest_base_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")