diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-09-07 14:01:20 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-09-13 13:32:34 +0200 |
commit | e726eb40eabc29beacb18d174b3b75217326a7b9 (patch) | |
tree | c5766a94edbb7a842de7d6f30ff93cddc0c30e18 /pylint | |
parent | ebae36e35447f113649b87a5dd7a3e03b793605c (diff) | |
download | pylint-git-e726eb40eabc29beacb18d174b3b75217326a7b9.tar.gz |
Type ``process_module`` and update argument names
Diffstat (limited to 'pylint')
-rw-r--r-- | pylint/checkers/format.py | 2 | ||||
-rw-r--r-- | pylint/checkers/misc.py | 12 | ||||
-rw-r--r-- | pylint/checkers/similar.py | 2 | ||||
-rw-r--r-- | pylint/checkers/strings.py | 4 | ||||
-rw-r--r-- | pylint/extensions/empty_comment.py | 4 | ||||
-rw-r--r-- | pylint/interfaces.py | 4 |
6 files changed, 17 insertions, 11 deletions
diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py index ffd1b2169..62064b88b 100644 --- a/pylint/checkers/format.py +++ b/pylint/checkers/format.py @@ -351,7 +351,7 @@ class FormatChecker(BaseTokenChecker): self._lines[line_num] = line.split("\n")[0] self.check_lines(line, line_num) - def process_module(self, _module): + def process_module(self, _node: nodes.Module) -> None: pass def _check_keyword_parentheses( diff --git a/pylint/checkers/misc.py b/pylint/checkers/misc.py index e53935adf..60d30c91b 100644 --- a/pylint/checkers/misc.py +++ b/pylint/checkers/misc.py @@ -29,6 +29,8 @@ import re import tokenize +from astroid import nodes + from pylint.checkers import BaseChecker from pylint.interfaces import IRawChecker, ITokenChecker from pylint.message import MessagesHandlerMixIn @@ -50,11 +52,11 @@ class ByIdManagedMessagesChecker(BaseChecker): } options = () - def process_module(self, module): + def process_module(self, node: nodes.Module) -> None: """Inspect the source file to find messages activated or deactivated by id.""" managed_msgs = MessagesHandlerMixIn.get_by_id_managed_msgs() for (mod_name, msgid, symbol, lineno, is_disabled) in managed_msgs: - if mod_name == module.name: + if mod_name == node.name: verb = "disable" if is_disabled else "enable" txt = f"'{msgid}' is cryptic: use '# pylint: {verb}={symbol}' instead" self.add_message("use-symbolic-message-instead", line=lineno, args=txt) @@ -125,11 +127,11 @@ class EncodingChecker(BaseChecker): self.add_message("syntax-error", line=lineno, args=msg) return None - def process_module(self, module): + def process_module(self, node: nodes.Module) -> None: """inspect the source file to find encoding problem""" - encoding = module.file_encoding if module.file_encoding else "ascii" + encoding = node.file_encoding if node.file_encoding else "ascii" - with module.stream() as stream: + with node.stream() as stream: for lineno, line in enumerate(stream): self._check_encoding(lineno + 1, line, encoding) diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index 88d7eac52..fb92e7035 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -820,7 +820,7 @@ class SimilarChecker(BaseChecker, Similar, MapReduceMixin): nb_duplicated_lines=0, percent_duplicated_lines=0 ) - def process_module(self, node): + def process_module(self, node: nodes.Module) -> None: """process a module the module's content is accessible via the stream object diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py index d05fc3c30..ae020594f 100644 --- a/pylint/checkers/strings.py +++ b/pylint/checkers/strings.py @@ -710,8 +710,8 @@ class StringConstantChecker(BaseTokenChecker): super().__init__(*args, **kwargs) self.string_tokens = {} # token position -> (token value, next token) - def process_module(self, module): - self._unicode_literals = "unicode_literals" in module.future_imports + def process_module(self, node: nodes.Module) -> None: + self._unicode_literals = "unicode_literals" in node.future_imports def process_tokens(self, tokens): encoding = "ascii" diff --git a/pylint/extensions/empty_comment.py b/pylint/extensions/empty_comment.py index a6f2ede75..7b9841678 100644 --- a/pylint/extensions/empty_comment.py +++ b/pylint/extensions/empty_comment.py @@ -1,3 +1,5 @@ +from astroid import nodes + from pylint.checkers import BaseChecker from pylint.interfaces import IRawChecker @@ -43,7 +45,7 @@ class CommentChecker(BaseChecker): options = () priority = -1 # low priority - def process_module(self, node): + def process_module(self, node: nodes.Module) -> None: with node.stream() as stream: for (line_num, line) in enumerate(stream): line = line.rstrip() diff --git a/pylint/interfaces.py b/pylint/interfaces.py index 02ed031f9..cac7e76c3 100644 --- a/pylint/interfaces.py +++ b/pylint/interfaces.py @@ -18,6 +18,8 @@ """Interfaces for Pylint objects""" from collections import namedtuple +from astroid import nodes + Confidence = namedtuple("Confidence", ["name", "description"]) # Warning Certainties HIGH = Confidence("HIGH", "No false positive possible.") @@ -66,7 +68,7 @@ class IChecker(Interface): class IRawChecker(IChecker): """interface for checker which need to parse the raw file""" - def process_module(self, astroid): + def process_module(self, node: nodes.Module) -> None: """process a module the module's content is accessible via astroid.stream |