Skip to content
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
6 changes: 6 additions & 0 deletions doc/whatsnew/fragments/8473.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Following a deprecation period, the ``py_version`` argument of the
``MessageDefinition.may_be_emitted`` function is now required. The most likely solution
is to use 'linter.config.py_version' if you need to keep using this
function, or to use 'MessageDefinition.is_message_enabled' instead.

Refs #8473
20 changes: 2 additions & 18 deletions pylint/message/message_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from __future__ import annotations

import sys
import warnings
from typing import TYPE_CHECKING, Any

from astroid import nodes
Expand Down Expand Up @@ -73,23 +72,8 @@ def __repr__(self) -> str:
def __str__(self) -> str:
return f"{repr(self)}:\n{self.msg} {self.description}"

def may_be_emitted(
self,
py_version: tuple[int, ...] | sys._version_info | None = None,
) -> bool:
"""Return True if message may be emitted using the configured py_version."""
if py_version is None:
py_version = sys.version_info
# TODO: 3.0
warnings.warn(
"'py_version' will be a required parameter of "
"'MessageDefinition.may_be_emitted' in pylint 3.0. The most likely "
"solution is to use 'linter.config.py_version' if you need to keep "
"using this function, or to use 'MessageDefinition.is_message_enabled'"
" instead.",
DeprecationWarning,
stacklevel=2,
)
def may_be_emitted(self, py_version: tuple[int, ...] | sys._version_info) -> bool:
"""May the message be emitted using the configured py_version?"""
if self.minversion is not None and self.minversion > py_version:
return False
if self.maxversion is not None and self.maxversion <= py_version:
Expand Down