diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-03-07 10:12:35 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-03-07 10:39:07 +0100 |
commit | fb65f75846ff4a81cced80f9d1ed09bda6f80475 (patch) | |
tree | c5b447f1a437898f267a1950f2cbfae0c4527726 | |
parent | f8e7b1342bf4091b27d1487e617a94a5b8d09019 (diff) | |
download | pylint-git-fb65f75846ff4a81cced80f9d1ed09bda6f80475.tar.gz |
Add typing that were lacking following refactor
See : 6721cd1cf2da0294124b75d382a042e23ec27d47
-rw-r--r-- | examples/deprecation_checker.py | 6 | ||||
-rw-r--r-- | pylint/checkers/deprecated.py | 16 |
2 files changed, 9 insertions, 13 deletions
diff --git a/examples/deprecation_checker.py b/examples/deprecation_checker.py index 03b8e3e36..fba6a54de 100644 --- a/examples/deprecation_checker.py +++ b/examples/deprecation_checker.py @@ -38,7 +38,7 @@ from module mymodule: ------------------------------------------------------------------ Your code has been rated at 2.00/10 (previous run: 2.00/10, +0.00) """ - +from typing import Set, Tuple from pylint.checkers import BaseChecker, DeprecatedMixin from pylint.interfaces import IAstroidChecker @@ -56,7 +56,7 @@ class DeprecationChecker(DeprecatedMixin, BaseChecker): # The name defines a custom section of the config for this checker. name = "deprecated" - def deprecated_methods(self): + def deprecated_methods(self) -> Set: """Callback method called by DeprecatedMixin for every method/function found in the code. Returns: @@ -64,7 +64,7 @@ class DeprecationChecker(DeprecatedMixin, BaseChecker): """ return {"mymodule.deprecated_function", "mymodule.MyClass.deprecated_method"} - def deprecated_arguments(self, method: str): + def deprecated_arguments(self, method: str) -> Tuple: """Callback returning the deprecated arguments of method/function. Returns: diff --git a/pylint/checkers/deprecated.py b/pylint/checkers/deprecated.py index 358c88ee4..8fe491c15 100644 --- a/pylint/checkers/deprecated.py +++ b/pylint/checkers/deprecated.py @@ -2,7 +2,7 @@ # For details: https://github.com/PyCQA/pylint/blob/master/COPYING """Checker mixin for deprecated functionality.""" - +from collections.abc import Iterable from itertools import chain from typing import Any @@ -39,20 +39,16 @@ class DeprecatedMixin: "deprecated-method", "deprecated-argument", ) - def visit_call(self, node): - """Called when a :class:`.astroid.node_classes.Call` node is visited. - - Args: - node (astroid.node_classes.Call): The node to check. - """ + def visit_call(self, node: astroid.node_classes.Call) -> None: + """Called when a :class:`.astroid.node_classes.Call` node is visited.""" try: for inferred in node.func.infer(): # Calling entry point for deprecation check logic. self.check_deprecated_method(node, inferred) except astroid.InferenceError: - return + pass - def deprecated_methods(self): + def deprecated_methods(self) -> Iterable: """Callback returning the deprecated methods/functions. Returns: @@ -61,7 +57,7 @@ class DeprecatedMixin: # pylint: disable=no-self-use return () - def deprecated_arguments(self, method: str): + def deprecated_arguments(self, method: str) -> Iterable: """Callback returning the deprecated arguments of method/function. Args: |