[code-quality] Minimal example

Claudiu Popa pcmanticore at gmail.com
Sun Aug 14 09:32:16 EDT 2016


On Sat, Aug 13, 2016 at 11:31 AM, mrx <patrik.mrx at gmail.com> wrote:

> Hi,
>
> Where can i find a bare minimum pylint checker that will successfully be
> registered and called?
>
> I've tried to write a checker like so:
> $ cat mychecker.py
> from pylint import checkers
> import pdb
>
> class Foo(checkers.BaseChecker):
>
>     name = "FooBar"
>
>     def visit_module(self, node):
>         self.add_message('blaha-name', node=node)
>         pdb.set_trace()
>
>     def visit_importfrom(self, node):
>         self.add_message('foo-name', node=node)
>         pdb.set_trace()
>
>     def visit_import(self, node):
>         self.add_message('bar-name', node=node)
>         pdb.set_trace()
>
> def register(linter):
>     linter.register_checker(Foo(linter))
>     print "Mychecker registered successfully it seems"
>
> I get the print from register but neither of my visit_* methods seems to
> get called, i cannot see why.
>
> I run it like so:
> PYTHONPATH=. pylint --load-plugins=mychecker -rn  main.py testmodule
>
> What am i missing?
>
>
>

Hi,

You will have to provide as well the message dictionary that you checker
is going to emit. I just documented this here:
https://docs.pylint.org/en/latest/custom_checkers.html#writing-your-own-checker

This part needs more documentation work though, so if you notice
any other inconsistency, let me know.


Claudiu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/code-quality/attachments/20160814/90b0bcb6/attachment.html>


More information about the code-quality mailing list