From e666506158feab03630c37dfb9bf9fd498f7a52a Mon Sep 17 00:00:00 2001 From: Matus Valo Date: Thu, 16 Jun 2022 11:32:10 +0200 Subject: Add support of sharing message in multiple checkers. Fix DeprecatedChecker example (#6693) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move message definitions from DeprecatedMixin * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added typing and fixed unittests * Make DEPRECATED_MSGS and DEPRECATED_IMPORT_MSG class variables to make pylint happy * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Introduce shared messages * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Change Message codes in DeprecatedMixin to W49XX * Make mypy happy * Make pylint happy * Add support for building documentation for shared messages * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Make isort happy * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Circuvent isort * Move shared to extra message options and fix tests * Update deprecation_checker example * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update doc/exts/pylint_messages.py Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> * Update doc/exts/pylint_messages.py Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> * Make messages static class attributes * Keep MessageDefinition backward compatible * Apply suggestions from code review Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> --- pylint/checkers/stdlib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pylint/checkers/stdlib.py') diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py index 8aa5fc8f6..2e6f8c182 100644 --- a/pylint/checkers/stdlib.py +++ b/pylint/checkers/stdlib.py @@ -15,6 +15,7 @@ from astroid import nodes from pylint import interfaces from pylint.checkers import BaseChecker, DeprecatedMixin, utils +from pylint.typing import MessageDefinitionTuple if TYPE_CHECKING: from pylint.lint import PyLinter @@ -332,8 +333,11 @@ def _check_mode_str(mode): class StdlibChecker(DeprecatedMixin, BaseChecker): name = "stdlib" - msgs = { - **{k: v for k, v in DeprecatedMixin.msgs.items() if k[1:3] == "15"}, + msgs: dict[str, MessageDefinitionTuple] = { + **DeprecatedMixin.DEPRECATED_METHOD_MESSAGE, + **DeprecatedMixin.DEPRECATED_ARGUMENT_MESSAGE, + **DeprecatedMixin.DEPRECATED_CLASS_MESSAGE, + **DeprecatedMixin.DEPRECATED_DECORATOR_MESSAGE, "W1501": ( '"%s" is not a valid mode for open.', "bad-open-mode", -- cgit v1.2.1