Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cannot get pylint to register custom checker, is there a missing step in the docs? #7264

Closed
@daogilvie

Description

@daogilvie

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp