diff options
author | Dani Alcala <112832187+clavedeluna@users.noreply.github.com> | 2022-10-13 13:16:01 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 18:16:01 +0200 |
commit | b6a7ed1287ef3a3888b807565cf2779050778e44 (patch) | |
tree | ea5a5aa04d0b4986f8141db6bdadbdda6a13e292 /pylint/message | |
parent | b531c99f6eefb01d577f76b7e8661657c7fa547b (diff) | |
download | pylint-git-b6a7ed1287ef3a3888b807565cf2779050778e44.tar.gz |
Use 'py-version' when accounting for max/min version of checker (#7580)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'pylint/message')
-rw-r--r-- | pylint/message/message_definition.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/pylint/message/message_definition.py b/pylint/message/message_definition.py index 3b403b008..a44e6b780 100644 --- a/pylint/message/message_definition.py +++ b/pylint/message/message_definition.py @@ -5,6 +5,7 @@ from __future__ import annotations import sys +import warnings from typing import TYPE_CHECKING, Any from astroid import nodes @@ -70,11 +71,24 @@ class MessageDefinition: def __str__(self) -> str: return f"{repr(self)}:\n{self.msg} {self.description}" - def may_be_emitted(self) -> bool: - """Return True if message may be emitted using the current interpreter.""" - if self.minversion is not None and self.minversion > sys.version_info: + 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 + 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, + ) + if self.minversion is not None and self.minversion > py_version: return False - if self.maxversion is not None and self.maxversion <= sys.version_info: + if self.maxversion is not None and self.maxversion <= py_version: return False return True |