summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMatus Valo <matusvalo@users.noreply.github.com>2022-06-16 11:32:10 +0200
committerGitHub <noreply@github.com>2022-06-16 11:32:10 +0200
commite666506158feab03630c37dfb9bf9fd498f7a52a (patch)
treece1c4a9d3f18c440f4e81f0d4a8785acdcddf53f /examples
parent600a47e13e3df1ca42521c653ab0ebed5739d485 (diff)
downloadpylint-git-e666506158feab03630c37dfb9bf9fd498f7a52a.tar.gz
Add support of sharing message in multiple checkers. Fix DeprecatedChecker example (#6693)
* 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>
Diffstat (limited to 'examples')
-rw-r--r--examples/deprecation_checker.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/deprecation_checker.py b/examples/deprecation_checker.py
index 52244edf6..6fb21eedd 100644
--- a/examples/deprecation_checker.py
+++ b/examples/deprecation_checker.py
@@ -51,14 +51,20 @@ if TYPE_CHECKING:
class DeprecationChecker(DeprecatedMixin, BaseChecker):
"""Class implementing deprecation checker."""
- # DeprecationMixin class is Mixin class implementing logic for searching deprecated methods and functions.
- # The list of deprecated methods/functions is defined by implementing class via deprecated_methods callback.
+ # DeprecatedMixin class is Mixin class implementing logic for searching deprecated methods and functions.
+ # The list of deprecated methods/functions is defined by the implementing class via deprecated_methods callback.
# DeprecatedMixin class is overriding attributes of BaseChecker hence must be specified *before* BaseChecker
# in list of base classes.
# The name defines a custom section of the config for this checker.
name = "deprecated"
+ # Register messages emitted by the checker.
+ msgs = {
+ **DeprecatedMixin.DEPRECATED_METHOD_MESSAGE,
+ **DeprecatedMixin.DEPRECATED_ARGUMENT_MESSAGE,
+ }
+
def deprecated_methods(self) -> set[str]:
"""Callback method called by DeprecatedMixin for every method/function found in the code.