Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure with pylint-2.15.0: pylint_plugin_utils.NoSuchChecker: <class 'pylint.checkers.typecheck.TypeChecker'> #27

Closed
atodorov opened this issue Aug 26, 2022 · 15 comments

Comments

@atodorov
Copy link
Contributor

atodorov commented Aug 26, 2022

PYTHONPATH=.:"../Kiwi/" pylint \
    --load-plugins=pylint.extensions.no_self_use \
    --load-plugins=pylint_django --django-settings-module=test_project.settings \
    --load-plugins=kiwi_lint -d similar-string \
    -d missing-docstring -d duplicate-code -d module-in-directory-without-init \
    --ignore migrations \
    *.py tcms_settings_dir/ trackers_integration/ test_project/
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/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__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.13/x64/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/__init__.py", line 35, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/run.py", line 151, in __init__
    linter.load_plugin_modules(self._plugins)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 371, in load_plugin_modules
    module.register(self)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint_django/plugin.py", line 44, in register
    apply_augmentations(linter)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint_django/augmentations/__init__.py", line 840, in apply_augmentations
    augment_visit(linter, TypeChecker.visit_attribute, foreign_key_sets)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint_plugin_utils/__init__.py", line 46, in augment_visit
    checker = get_checker(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/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'>
make: *** [Makefile:13: pylint] Error 1

https://github.com/kiwitcms/trackers-integration/runs/8037795176?check_suite_focus=true

  • pylint-2.15.0
  • pylint-django-2.5.3
  • pylint-plugin-utils-0.7

Previous PASSING execution in my CI, https://github.com/kiwitcms/trackers-integration/runs/7983170188?check_suite_focus=true, was with

  • pylint-2.14.5
  • pylint-django-2.5.3
  • pylint-plugin-utils-0.7

@carlio I'm not sure if I will be able to take a look at this over the weekend. I will try.

atodorov added a commit to kiwitcms/trackers-integration that referenced this issue Aug 26, 2022
atodorov added a commit to kiwitcms/trackers-integration that referenced this issue Aug 26, 2022
@carlio
Copy link
Collaborator

carlio commented Aug 26, 2022

@DanielNoord @Pierre-Sassoulas do you happen to know what in 2.15 caused this? You might get some pylint-django bugs on the main pylint tracker from this, point them here if so. @atodorov I'll also try to find time too over the weekend, it's probably a deprecation I never got around to removing.

@Pierre-Sassoulas
Copy link
Member

We did not move the TypeChecker:

https://github.com/PyCQA/pylint/blob/646fef2339b576a596eb8a026393a17da31b7b97/pylint/checkers/typecheck.py#L813

So the reason of the crash is not straightforward, it seems like a bug. But this ring a bell. Maybe something to do with plugin discoverability, the order of option and using load-plugin both in pylintrc and CLI options (as not yet documented in pylint-dev/pylint#7276 ?). Does the following would help ?

The preferred way of making this plugin available to pylint is
by installing it as a package. This can be done either from a packaging index like
PyPI or by installing it from a local source such as with pip install ..

Alternatively, the plugin module can be made available to pylint by
putting this module's parent directory in your ``PYTHONPATH``
environment variable.
If your pylint config has an init-hook that modifies
``sys.path`` to include the module's parent directory, this
will also work, but only if either:

* the ``init-hook`` and the ``load-plugins`` list are both
  defined in a pylintrc file, or...
* the ``init-hook`` is passed as a command-line argument and
  the ``load-plugins`` list is in the pylintrc file

This is because pylint loads plugins specified on command
line before loading any configuration from other sources.

@smoehrle
Copy link

So the reason of the crash is not straightforward, [...]

I can confirm this. We see the same issue in our pipeline, but I cannot reproduce it locally. I'm still figuring out what the slight differences between the CI environment and my laptop are but it's not only the versions mentioned in the initial post.

@atodorov
Copy link
Contributor Author

but it's not only the versions mentioned in the initial post

For me it's the same CI environment, same test job, only versions are different. Updated original comment with URL to passing job if you want to compare logs (before I applied a workaround).

@DanielNoord
Copy link

I also can't seem to reproduce this locally with:

git checkout https://github.com/kiwitcms/trackers-integration.git
cd trackers-integration
virtualenv venv python3.8
pip install -r devel.txt
git clone --depth 1 https://github.com/kiwitcms/Kiwi.git "../Kiwi/"
pip install -r ../Kiwi/requirements/devel.txt
pip install pylint==2.15
make check

I'm getting one missing-timeout error which seems correct, but no failure. Is anybody able to reproduce this locally? And not in CI?

@carlio
Copy link
Collaborator

carlio commented Aug 27, 2022

I also couldn't reproduce it with python 3.8.12 or 3.9.9 or 3.10.1 locally.

I looked at the trackers-integration CI config in case anything stood out, but didn't see anything. I thought perhaps that the github setup-python action could have changed but it is tagged at v4. No new python 3.8 releases either recently. Basically I was wondering if there are any CI requirements that are not completely pinned that could have changed.

@michael-k
Copy link
Contributor

michael-k commented Aug 29, 2022

Maybe something to do with plugin discoverability, the order of option and using load-plugin both in pylintrc and CLI options (as not yet documented in pylint-dev/pylint#7276?).

We also had this issue and were able to fix it by removing the line load-plugins = ["pylint_django"] from pyproject.toml. pylint-django==2.5.3 is installed via pip.

Update: That probably disabled the plugin pylint-django altogether. We're using pytest-pylint to run pylint and I was confused by the line plugins: django-4.5.2, pylint-0.18.0, mock-3.8.2, but that's talking about pytest-django of course.

@atodorov
Copy link
Contributor Author

I also couldn't reproduce it with python 3.8.12 or 3.9.9 or 3.10.1 locally.

I also was not able to reproduce locally. I am still fairly busy this week but is there any more information I can provide to figure out why the CI environment is different?

@WolfgangFellger
Copy link

I can drop a hint that it seems to hinge on astroid.
astroid 2.12.4 reproduces this reliably for me with both pylint 2.14.5 and 2.15.0.
Working combination is astroid 2.11.7 with pylint 2.14.5.

@michael-k
Copy link
Contributor

git bisect says this was caused by pylint-dev/astroid@5067f08 (PR: pylint-dev/astroid#1536)

It has been fixed in commit pylint-dev/astroid@8852ecd (PR: pylint-dev/astroid#1759) released with astroid 2.12.5 yesterday (2022-08-29).

I've verified the fix with 2 of our repositories that failed with astroid 2.12.4.

@Pierre-Sassoulas
Copy link
Member

Thanks a lot for the double bisection @michael-k, very helpful ! Reinstalling pylint from scratch or upgrading astroid manually should fix the issue then.

@DanielNoord
Copy link

Can any of the original reporters confirm that this has indeed been fixed? I would be somewhat surprised as the original stracktrace seems to point to pylint being at fault here, not astroid.

@atodorov
Copy link
Contributor Author

@DanielNoord :

astroid-2.12.5,
pylint-2.15.0,
pylint-django-2.5.3,
pylint-plugin-utils-0.7

Seems to work for me, see https://github.com/kiwitcms/trackers-integration/runs/8094609902?check_suite_focus=true.

The reported FAIL in the CI job above is pylint reporting errors on the code under inspection but it doesn't crash like in the original comment. From my POV this is now fixed.

@carlio
Copy link
Collaborator

carlio commented Aug 30, 2022

Ok so it looks like there's an incompatibility with exactly astroid 2.12.4 or something, but that this will only be a problem for projects who have pinned that exact version. pylint-django and pylint-plugin-utils explicitly only declare very permissive pylint version ranges and nothing else as a dependency to avoid clashes with other CI and linting dependencies.

I think this is just stale pip caches in CI to be honest; especially as nobody could reproduce it locally with a fresh venv. Doesn't seem like a problem which can be fixed in this repo so I'll close this.

@carlio carlio closed this as completed Aug 30, 2022
@carlio
Copy link
Collaborator

carlio commented Aug 30, 2022

Thanks for all the input and work everyone :-) especially the git bisect work to find the cause!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants