diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-14 20:27:23 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-15 09:29:56 +0200 |
commit | 88077431950f0854e16759e8619fcbb4173b708b (patch) | |
tree | dd6136164cc97e8e2c0826430f513ae5dd8ee0ff /pylint/testutils | |
parent | 9841051f7cfa931dbe7643208910a162c3940d09 (diff) | |
download | pylint-git-88077431950f0854e16759e8619fcbb4173b708b.tar.gz |
Add handle_message in BaseReporter and add typing
Diffstat (limited to 'pylint/testutils')
-rw-r--r-- | pylint/testutils/reporter_for_tests.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/pylint/testutils/reporter_for_tests.py b/pylint/testutils/reporter_for_tests.py index 1cb4b4a59..e56a0e284 100644 --- a/pylint/testutils/reporter_for_tests.py +++ b/pylint/testutils/reporter_for_tests.py @@ -3,8 +3,10 @@ from io import StringIO from os import getcwd, linesep, sep +from typing import Dict, List from pylint import interfaces +from pylint.message import Message from pylint.reporters import BaseReporter @@ -14,21 +16,20 @@ class GenericTestReporter(BaseReporter): __implements__ = interfaces.IReporter def __init__(self): # pylint: disable=super-init-not-called - - self.message_ids = {} self.reset() - self.path_strip_prefix = getcwd() + sep def reset(self): + self.message_ids: Dict = {} self.out = StringIO() - self.messages = [] + self.path_strip_prefix: str = getcwd() + sep + self.messages: List[str] = [] - def handle_message(self, msg): + def handle_message(self, msg: Message) -> None: """manage message of different type and in the context of path""" obj = msg.obj line = msg.line msg_id = msg.msg_id - msg = msg.msg + str_message: str = msg.msg self.message_ids[msg_id] = 1 if obj: obj = ":%s" % obj @@ -36,8 +37,8 @@ class GenericTestReporter(BaseReporter): if linesep != "\n": # 2to3 writes os.linesep instead of using # the previously used line separators - msg = msg.replace("\r\n", "\n") - self.messages.append(f"{sigle}:{line:>3}{obj}: {msg}") + str_message = str_message.replace("\r\n", "\n") + self.messages.append(f"{sigle}:{line:>3}{obj}: {str_message}") def finalize(self): self.messages.sort() @@ -60,9 +61,6 @@ class GenericTestReporter(BaseReporter): class MinimalTestReporter(BaseReporter): - def handle_message(self, msg): - self.messages.append(msg) - def on_set_current_module(self, module, filepath): self.messages = [] @@ -70,9 +68,6 @@ class MinimalTestReporter(BaseReporter): class FunctionalTestReporter(BaseReporter): # pylint: disable=abstract-method - def handle_message(self, msg): - self.messages.append(msg) - def on_set_current_module(self, module, filepath): self.messages = [] |