[Python-projects] PyLint 0.12.0: custom reporter is ignored

Maarten ter Huurne maarten.ter.huurne at philips.com
Thu Sep 21 19:25:17 CEST 2006


Hi,

I'm using a custom reporter to generate HTML in a style that is easier to 
read for me. After upgrading to PyLint 0.12.0, this custom reporter is no 
longer called; instead the text reporter is called. I try to install the 
reporter by passing the "reporter" argument to the "Run" class, which 
passes it to the "PyLinter" class. This custom reporter is passed to 
"set_reporter", but later overwritten with a TextReporter on two 
occasions:

===
  File "/home/huurnem/fab/client/wrappers/pylint/pylint-custom.py", line 
310, in ?
    lint.Run(params, reporter = CustomReporter(sys.stdout, extractedFile))
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 798, in 
__init__
    reporter=reporter, pylintrc=self._rcfile)
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 284, in 
__init__
    self.register_checker(self)
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 346, in 
register_checker
    checker.load_defaults()
  File "/usr/lib/python2.4/site-packages/logilab/common/configuration.py", 
line 608, in load_defaults
    self.set_option(opt_name, default, action, opt_dict)
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 322, in 
set_option
    self.set_reporter(REPORTER_OPT_MAP[value.lower()]())
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 302, in 
set_reporter
===
  File "/home/huurnem/fab/client/wrappers/pylint/pylint-custom.py", line 
310, in ?
    lint.Run(params, reporter = CustomReporter(sys.stdout, extractedFile))
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 798, in 
__init__
    reporter=reporter, pylintrc=self._rcfile)
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 286, in 
__init__
    self.load_provider_defaults()
  File "/usr/lib/python2.4/site-packages/logilab/common/configuration.py", 
line 446, in load_provider_defaults
    provider.load_defaults()
  File "/usr/lib/python2.4/site-packages/logilab/common/configuration.py", 
line 608, in load_defaults
    self.set_option(opt_name, default, action, opt_dict)
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 322, in 
set_option
    self.set_reporter(REPORTER_OPT_MAP[value.lower()]())
  File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 302, in 
set_reporter
===

The line numbers might vary slightly because I added some debug 
statements, but shouldn't be off by more than a couple of lines.

Should I be using a different procedure to register a custom reporter, or 
is the custom reporter mechanism broken in PyLint 0.12.0?

For now, I solved it with the following change in the constructor of 
PyLinter:

===
--- lint.py.org 2006-09-21 19:18:18.000000000 +0200
+++ lint.py     2006-09-21 19:17:08.000000000 +0200
@@ -244,7 +244,6 @@
         #
         # checkers / reporter / astng manager
         self.reporter = None
-        self.set_reporter(reporter or TextReporter(sys.stdout))
         self.manager = ASTNGManager()
         self._checkers = {}
         # visit variables
@@ -284,6 +283,10 @@
         self.register_checker(self)
         self._dynamic_plugins = []
         self.load_provider_defaults()
+        # MtH: Custom reporter should override any reporter that is 
selected
+        #      by default or configuration.
+        if reporter is not None:
+            self.set_reporter(reporter)

     def load_plugin_modules(self, modnames):
         """take a list of module names which are pylint plugins and load
===

By the way, I like the fact that the "linter" instance is now set on the 
reporter; this simplifies my custom reporter a bit.

Bye,
                Maarten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.logilab.org/pipermail/python-projects/attachments/20060921/d95426b9/attachment.html


More information about the Python-Projects mailing list