Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.2k
Description
Question
Hi! First: Thanks for supporting and maintaining such a great ecosystem!
My question: I'm trying to make a simple checker around some custom formatting in log strings. I have followed every tutorial I can find from within the last few years, and naturally looked at the guidein the documentation.
However, I am finding that theregister
function, described as the way to get your checker actually loaded into pylint, simply is not being called. The module is being loaded, for sure — I can see breakpoints in the top level of the module being hit, but not in theregister
function itself. I've tried setting the--load-plugins
argument, I've tried using theload_plugins
setting in pylintrc.
Is there an additional step or constraint missing in the implementation of custom checkers from the docs? Or am I simply making a mistake?
Below is the code for my absolute bare-bones first attempt.
Stored intestchecker.py
:
fromastroidimportnodesfrompylint.checkersimportBaseCheckerbreakpoint()# HIT!classSimpleCheck(BaseChecker):"""Simple"""name="simple-test-check"msgs= {"W6900": ("Test","test-check","Just a test") }options= ( ("fake-option", {"default":False,"type":"yn",# EDIT: bool here was not allowed"metavar":"<y or n>","help":"Some fake option"} ), )defvisit_import(self,_:nodes.Import)->None:breakpoint()# NOT HIT!defregister(linter):breakpoint()# NOT HIT!linter.register_checker(SimpleCheck(linter))
My file I am linting,lintme.py
:
"""MODULE DOCSTRING"""importlogginglogger=logging.getLogger(__name__)logger.info("hello world")
Both files are in the same directory, in which I execute:
pylint --load-plugins=testchecker lintme.py
$ pylint --versionpylint 2.14.5astroid 2.11.7Python 3.10.4 (main, May 19 2022, 08:51:27) [Clang 13.1.6 (clang-1316.0.21.2.5)]$ uname -aDarwin OVO4941L.ovoenergy.local 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 x86_64
Thanks again!
Documentation for future user
I expect the guide to creating a custom checker to contain everything needed to do so, and to have a section highlighting common and easy mistakes (I'm assuming I have made such a mistake)
Additional context
I have searched stack overflow and pre-existing issues on this repo, and not found anyone reporting this.
There ishttps://stackoverflow.com/questions/71590677/cant-load-custom-pylint-module, but they report getting an error about not finding the module, then succeeding by placing the module in the pylint source. This is not what I am experiencing.