pylint-dev / pylint-django

Pylint plugin for improving code analysis for when using Django
Other
591 stars 117 forks source link

Pylint 2.15 Raise pylint_plugin_utils.NoSuchChecker on Windows #378

Open obi-081 opened 1 year ago

obi-081 commented 1 year ago

Hi, If I upgrade PyLint to 2.15.x, I can't load the pylint_django plugin anymore. It raise pylint_plugin_utils.NoSuchChecker: <class 'pylint.checkers.typecheck.TypeChecker'>

Can you reproduce this problem too ?

I'm on Windows 11 (sorry ^_^) Python 3.10.8 astroid==2.12.12 Django==4.0.8 pylint==2.15.5 pylint-django==2.5.3 pylint-plugin-utils==0.7

Here's an example of what I get:

D:\Work\django>django-admin startproject mysite
D:\Work\django>cd mysite
D:\Work\django\mysite>pylint mysite --django-settings-module=mysite.settings --load-plugins=pylint_django
Traceback (most recent call last):
  File "C:\Python3\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:\Python3\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python3\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python3\Scripts\pylint.exe\__main__.py", line 7, in <module>
  File "C:\Python3\lib\site-packages\pylint\__init__.py", line 35, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "C:\Python3\lib\site-packages\pylint\lint\run.py", line 151, in __init__
    linter.load_plugin_modules(self._plugins)
  File "C:\Python3\lib\site-packages\pylint\lint\pylinter.py", line 376, in load_plugin_modules
    module.register(self)
  File "C:\Python3\lib\site-packages\pylint_django\plugin.py", line 44, in register
    apply_augmentations(linter)
  File "C:\Python3\lib\site-packages\pylint_django\augmentations\__init__.py", line 840, in apply_augmentations
    augment_visit(linter, TypeChecker.visit_attribute, foreign_key_sets)
  File "C:\Python3\lib\site-packages\pylint_plugin_utils\__init__.py", line 46, in augment_visit
    checker = get_checker(
  File "C:\Python3\lib\site-packages\pylint_plugin_utils\__init__.py", line 28, in get_checker
    raise NoSuchChecker(checker_class)
pylint_plugin_utils.NoSuchChecker: <class 'pylint.checkers.typecheck.TypeChecker'>

After a pip install "pylint<2.15", it works well.

Here's my full pip freeze : https://www.dropbox.com/s/e0i9enof9r71rzi/pip-freeze.txt?dl=0

Thanks !

Jerome

obi-081 commented 1 year ago

I tested the Same configuration on Linux and got the Issue #370 instead so this one is Windows Only

millsks commented 8 months ago

I came across this issue on Linux recently. I had to downgrade pylint from 2.17.7 to <2.15 and that error went away.