summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatus Valo <matusvalo@gmail.com>2021-02-20 22:01:03 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-02-21 11:41:20 +0100
commit34cce21d29f9692a34fec22a76bee70939e628a5 (patch)
tree3641d748277c8d2d0259f3a3bc517173da963702
parent30af955a7434952020416827b2482095866910e4 (diff)
downloadpylint-git-34cce21d29f9692a34fec22a76bee70939e628a5.tar.gz
Move message definition to the DeprecatedMixin class
-rw-r--r--examples/deprecation_checker.py20
-rw-r--r--pylint/checkers/deprecated.py9
-rw-r--r--pylint/checkers/stdlib.py2
3 files changed, 16 insertions, 15 deletions
diff --git a/examples/deprecation_checker.py b/examples/deprecation_checker.py
index a6a8e3963..7059c89ab 100644
--- a/examples/deprecation_checker.py
+++ b/examples/deprecation_checker.py
@@ -33,25 +33,17 @@ from pylint.checkers import BaseChecker, DeprecatedMixin, utils
from pylint.interfaces import IAstroidChecker
-class DeprecationChecker(BaseChecker, DeprecatedMixin):
+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 implemeting class via deprecated_methods callback.
+ # DeprecatedMixin class is overriding attrigutes of BaseChecker hence must be specified *before* BaseChecker
+ # in list of base classes.
+
__implements__ = (IAstroidChecker,)
# The name defines a custom section of the config for this checker.
name = "deprecated"
- # This class variable declares the messages (ie the warnings and errors)
- # that the checker can emit.
- msgs = {
- # Each message has a code, a message that the user will see,
- # a unique symbol that identifies the message,
- # and a detailed help message
- # that will be included in the documentation.
- "W1505": (
- "Using deprecated method %s()",
- "deprecated-method",
- "The method is marked as deprecated and will be removed in the future.",
- ),
- }
@utils.check_messages(
"deprecated-method",
diff --git a/pylint/checkers/deprecated.py b/pylint/checkers/deprecated.py
index 0bbad05ee..54254340d 100644
--- a/pylint/checkers/deprecated.py
+++ b/pylint/checkers/deprecated.py
@@ -4,6 +4,7 @@
"""Checker mixin for deprecated functionality."""
import abc
+from typing import Any
import astroid
@@ -19,6 +20,14 @@ class DeprecatedMixin(metaclass=abc.ABCMeta):
A class imlementing mixin must define "deprecated-method" Message.
"""
+ msgs: Any = {
+ "W1505": (
+ "Using deprecated method %s()",
+ "deprecated-method",
+ "The method is marked as deprecated and will be removed in the future.",
+ ),
+ }
+
@abc.abstractmethod
def deprecated_methods(self):
"""Callback returning the deprecated methods/functions.
diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py
index ad6e4f855..26bce9435 100644
--- a/pylint/checkers/stdlib.py
+++ b/pylint/checkers/stdlib.py
@@ -80,7 +80,7 @@ def _check_mode_str(mode):
return True
-class StdlibChecker(BaseChecker, DeprecatedMixin):
+class StdlibChecker(DeprecatedMixin, BaseChecker):
__implements__ = (IAstroidChecker,)
name = "stdlib"