Thanks, i got it to work now.
I have some feedback on the page you referred to.
I was missing the implements line as well. This was not highlighted at all.
Bullet two concerning priority. How checkers are ordered (internally?)
doesn't help me to decide if i should set a negative priority close to
zero or very far from zero in order for the checker to be first or at
least among the first.
I interpret this page as a resource you'd give programmers new to pylint
checkers to get them started, awesome start! I think it would be really
helpful if the page gave a overview of how the AST is buid and how i'm
meant to access for example function variables in a function or the
identifiers defined in a module. Where can i find a list of all the
visit_* methods that i can use? I cannot find any class defining them
all, are they dynamically called somehow?
In examples directory referred to, looking at custom_raw.py. It
implements process_module() instead of visit_*. What is the difference?
When should i choose one over the other?
Thanks a lot for your assistance in getting my first checker running.
// Patrik
Den 2016-08-14 kl. 15:32, skrev Claudiu Popa:
On Sat, Aug 13, 2016 at 11:31 AM, mrx <patrik....@gmail.com
<mailto:patrik....@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
_______________________________________________
code-quality mailing list
code-quality@python.org
https://mail.python.org/mailman/listinfo/code-quality