diff options
author | Ashley Whetter <ashley@awhetter.co.uk> | 2018-05-16 12:25:11 -0700 |
---|---|---|
committer | Ashley Whetter <ashley@awhetter.co.uk> | 2019-02-09 13:40:30 -0800 |
commit | 8468a86bd5f32d5c3c5b5794b396892e3bee04e9 (patch) | |
tree | 491d4b3eab74cb3732e3343706d1f63fff5c1ec3 | |
parent | 342ab98a99b276c73edb6706ce61d53cc4853056 (diff) | |
download | pylint-git-8468a86bd5f32d5c3c5b5794b396892e3bee04e9.tar.gz |
Reporters no longer use a PyLinter
-rw-r--r-- | pylint/lint.py | 13 | ||||
-rw-r--r-- | pylint/reporters/__init__.py | 4 | ||||
-rw-r--r-- | pylint/reporters/json.py | 4 | ||||
-rw-r--r-- | pylint/reporters/text.py | 38 |
4 files changed, 15 insertions, 44 deletions
diff --git a/pylint/lint.py b/pylint/lint.py index d333ff2d9..29739f5dd 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -1404,20 +1404,18 @@ group are mutually exclusive.", def load_reporter(self): name = self._global_config.output_format.lower() if name in self._plugin_registry._reporters: - self._reporter = self._plugin_registry._reporters[name]() - self._linter.reporter = self._reporter + self._reporter = self._plugin_registry._reporters[name]( + config=self._global_config + ) self._plugin_registry.reporter = self._reporter - # TODO: Remove the need to do this - self._reporter.linter = self._linter else: try: reporter_class = self._load_reporter_class() except (ImportError, AttributeError): raise exceptions.InvalidReporterError(name) else: - self._reporter = reporter_class() - self._linter.reporter = self._reporter - self._reporter.linter = self._linter + self._reporter = reporter_class(config=self._global_config) + self._plugin_registry.reporter = self._reporter def _load_reporter_class(self): qname = self._global_config.output_format @@ -1621,6 +1619,7 @@ group are mutually exclusive.", ): continue + self._linter.reporter = self._reporter self._linter.check(module_desc, walker, rawcheckers, tokencheckers) # notify global end diff --git a/pylint/reporters/__init__.py b/pylint/reporters/__init__.py index c09ebdd0c..7e0fee5f5 100644 --- a/pylint/reporters/__init__.py +++ b/pylint/reporters/__init__.py @@ -51,8 +51,8 @@ class BaseReporter: extension = "" - def __init__(self, output=None): - self.linter = None + def __init__(self, output=None, config=None): + self.config = config self.section = 0 self.out = None self.out_encoding = None diff --git a/pylint/reporters/json.py b/pylint/reporters/json.py index 100ed5264..7d630e92e 100644 --- a/pylint/reporters/json.py +++ b/pylint/reporters/json.py @@ -24,8 +24,8 @@ class JSONReporter(BaseReporter): name = "json" extension = "json" - def __init__(self, output=sys.stdout): - BaseReporter.__init__(self, output) + def __init__(self, output=sys.stdout, config=None): + super().__init__(output, config) self.messages = [] def handle_message(self, msg): diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py index 07a6a2c53..c7f86fca9 100644 --- a/pylint/reporters/text.py +++ b/pylint/reporters/text.py @@ -129,13 +129,13 @@ class TextReporter(BaseReporter): extension = "txt" line_format = "{path}:{line}:{column}: {msg_id}: {msg} ({symbol})" - def __init__(self, output=None): - BaseReporter.__init__(self, output) + def __init__(self, output=None, config=None): + super().__init__(output, config) self._modules = set() self._template = self.line_format def on_set_current_module(self, module, filepath): - self._template = str(self.linter.config.msg_template or self.line_format) + self._template = str(self.config.msg_template or self.line_format) def write_message(self, msg): """Convenience method to write a formated message with class default template""" @@ -157,32 +157,6 @@ class TextReporter(BaseReporter): TextWriter().format(layout, self.out) -class ParseableTextReporter(TextReporter): - """a reporter very similar to TextReporter, but display messages in a form - recognized by most text editors : - - <filename>:<linenum>:<msg> - """ - - name = "parseable" - line_format = "{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" - - def __init__(self, output=None): - warnings.warn( - "%s output format is deprecated. This is equivalent " - "to --msg-template=%s" % (self.name, self.line_format), - DeprecationWarning, - ) - TextReporter.__init__(self, output) - - -class VSTextReporter(ParseableTextReporter): - """Visual studio text reporter""" - - name = "msvs" - line_format = "{path}({line}): [{msg_id}({symbol}){obj}] {msg}" - - class ColorizedTextReporter(TextReporter): """Simple TextReporter that colorizes text output""" @@ -197,8 +171,8 @@ class ColorizedTextReporter(TextReporter): "S": ("yellow", "inverse"), # S stands for module Separator } - def __init__(self, output=None, color_mapping=None): - TextReporter.__init__(self, output) + def __init__(self, output=None, color_mapping=None, config=None): + super().__init__(output, config) self.color_mapping = color_mapping or dict(ColorizedTextReporter.COLOR_MAPPING) ansi_terms = ["xterm-16color", "xterm-256color"] if os.environ.get("TERM") not in ansi_terms: @@ -245,6 +219,4 @@ class ColorizedTextReporter(TextReporter): def register(linter): """Register the reporter classes with the linter.""" linter.register_reporter(TextReporter) - linter.register_reporter(ParseableTextReporter) - linter.register_reporter(VSTextReporter) linter.register_reporter(ColorizedTextReporter) |