pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.18k stars 1.1k forks source link

Import error with Python 3.11 #9743

Closed tbutler-qontigo closed 1 week ago

tbutler-qontigo commented 1 week ago

Bug description

Using python 3.11 and any version 3 pylint there is an import error:

from pylint.interfaces import IAstroidChecker, ITokenChecker
ImportError: cannot import name 'IAstroidChecker' from 'pylint.interfaces' (/venv/lib/python3.11/site-packages/pylint/interfaces.py)

Using pylint < 3 works and I have heard that using e.g. python 3.9 also works


### Configuration

_No response_

### Command used

```shell
python -m pylint app  --rcfile=../.pylintrc

Pylint output

from pylint.interfaces import IAstroidChecker, ITokenChecker
ImportError: cannot import name 'IAstroidChecker' from 'pylint.interfaces' (/venv/lib/python3.11/site-packages/pylint/interfaces.py)

Expected behavior

pylint should work

Pylint version

pylint 3.2.3

OS / Environment

No response

Additional dependencies

No response

mbyrnepr2 commented 1 week ago

Hey. Try upgrading astroid which is a dependency of Pylint. Do you know which version of astroid is in your environment?

tbutler-qontigo commented 1 week ago

I am running on a standard github actions linux runner which apparently is using 2.3.17.0

Pierre-Sassoulas commented 1 week ago

Closing as astroid's version should be managed by pylint, setting/hard coding the astroid version is going to create issues. (If you encounter this problem don't set up astroid or set it to a version that is compatible with pylint after letting a dependency manager solve this for you).

tbutler-qontigo commented 1 week ago

@Pierre-Sassoulas I am not trying to change the vwersion of asteroid - that was someone else's suggestion. I am simply running on the standard github action runner with whatever version it comes with - apparently 2.3.17.0 How can pylint be made to work with python 11 on a standard ubuntu-latest github actions runner?

thanks

Pierre-Sassoulas commented 1 week ago

I think the issue is in github actions runner, they should not set the astroid version (pylint 3.2.3 is not compatible with the installed astroid). You can try to set the pylint version and the astroid version yourself with some pre-install script added to the github action or similar. Or open an issue and wait for a fix in the github action directly.

tbutler-qontigo commented 3 days ago

I'm not sure github would make a fix just for this one app. How would I set the asteroid version? It isn't something I am really familiar with - I am more on the devops side trying to get this to work in our CI pipeline than the python programming side. Thanks

Pierre-Sassoulas commented 3 days ago

If you're using pylint 3.2.3 then the required astroid should be set automatically to

https://github.com/pylint-dev/pylint/blob/918d2168e15662df90cfb993df100e566f69d418/pyproject.toml#L44

Unless something somewhere change the version of astroid, pylint is set correctly and should bring the proper dependencies on install. If you don't know what tool or script is ruining your day, you can install the proper astroid manually yourself with pip install "astroid>=3.2.2,<=3.3.0-dev0" (or another python tool than pip). It will work only for pylint 3.2.3 and will ruin your day again if the pylint version change.