fcfangcc / pylint-pydantic

A Pylint plugin to help Pylint understand the Pydantic
GNU General Public License v3.0
20 stars 4 forks source link

exception occurs related to MisdesignChecker when trying to use pylint with pydantic using this plugin. #31

Open kotoroshinoto opened 9 months ago

kotoroshinoto commented 9 months ago

Problem description

Tried to use this plugin with pylint to check my project.

this exception occurs:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\pylint_plugin_utils\__init__.py", line 44, in augment_visit
    checker = get_checker(linter, checker_method.__self__.__class__)
AttributeError: 'function' object has no attribute '__self__'. Did you mean: '__call__'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\pylint.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python310\lib\site-packages\pylint\__init__.py", line 34, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "C:\Program Files\Python310\lib\site-packages\pylint\lint\run.py", line 162, in __init__
    args = _config_initialization(
  File "C:\Program Files\Python310\lib\site-packages\pylint\config\config_initialization.py", line 61, in _config_initialization
    linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
  File "C:\Program Files\Python310\lib\site-packages\pylint\lint\pylinter.py", line 381, in load_plugin_modules
    module.register(self)
  File "C:\Program Files\Python310\lib\site-packages\pylint_pydantic\__init__.py", line 100, in register
    suppress_message(linter, MisdesignChecker.leave_classdef, 'too-few-public-methods', is_pydantic_config_class)
  File "C:\Program Files\Python310\lib\site-packages\pylint_plugin_utils\__init__.py", line 102, in suppress_message
    augment_visit(linter, checker_method, DoSuppress(linter, message_id_or_symbol, test_func))
  File "C:\Program Files\Python310\lib\site-packages\pylint_plugin_utils\__init__.py", line 46, in augment_visit
    checker = get_checker(linter, get_class(checker_method.__module__, checker_method.__qualname__))
  File "C:\Program Files\Python310\lib\site-packages\pylint_plugin_utils\__init__.py", line 28, in get_checker
    raise NoSuchChecker(checker_class)
pylint_plugin_utils.NoSuchChecker: <class 'pylint.checkers.design_analysis.MisdesignChecker'>

Steps to reproduce the problem

add this plugin name to the pylint rcfile to the variables defining plugins to load and extension whitelists

Specifications like the version of the project, operating system, or hardware

fcfangcc commented 9 months ago

I can't repeat this issue. Please more information, like

def list_dependencies():
    import json
    import sys
    from importlib.metadata import version
    dependencies = ["pylint", "pylint_plugin_utils", "astroid", "pydantic", "pylint_pydantic"]

    return json.dumps({i: version(i) for i in dependencies} | {"python": sys.version}, indent=4)

print(list_dependencies())

And had load any other plugins?