pylint-dev / astroid

A common base representation of python source code for pylint and other projects
https://pylint.readthedocs.io/projects/astroid/en/latest/
GNU Lesser General Public License v2.1
530 stars 275 forks source link

Astroid version 2.2 (with pylint 2.2) is causing exceptions #649

Closed jan11011977 closed 5 years ago

jan11011977 commented 5 years ago

A new version of astroid was just deployed which is causing pylint to crash. I have Pylint pinned to version 2.2.2. but I hadn't pinned astroid, so that package was upgraded to 2.2.0. This then caused the crash:

PS D:\shared\python\ctn-compass> D:\shared.venv3.7.1\python\ctn-compass\scripts\pylint --rcfile=..\pylintrc src Traceback (most recent call last): File "d:\shared.venv3.7.1\python\ctn-compass\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "d:\shared.venv3.7.1\python\ctn-compass\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "D:\shared.venv3.7.1\python\ctn-compass\scripts\pylint.exe__main.py", line 9, in File "d:\shared.venv3.7.1\python\ctn-compass\lib\site-packages\pylint__init__.py", line 20, in run_pylint Run(sys.argv[1:]) File "d:\shared.venv3.7.1\python\ctn-compass\lib\site-packages\pylint\lint.py", line 1608, in init__ linter.check(args) File "d:\shared.venv3.7.1\python\ctn-compass\lib\site-packages\pylint\lint.py", line 938, in check self._do_check(files_or_modules) File "d:\shared.venv3.7.1\python\ctn-compass\lib\site-packages\pylint\lint.py", line 1071, in _do_check self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers) File "d:\shared.venv3.7.1\python\ctn-compass\lib\site-packages\pylint\lint.py", line 1154, in check_astroid_module walker.walk(ast_node) File "d:\shared.venv3.7.1\python\ctn-compass\lib\site-packages\pylint\utils.py", line 1269, in walk self.walk(child) File "d:\shared.venv3.7.1\python\ctn-compass\lib\site-packages\pylint\utils.py", line 1266, in walk cb(astroid) File "d:\shared.venv3.7.1\python\ctn-compass\lib\site-packages\pylint\checkers\variables.py", line 1582, in visit_import module = next(node.infer_name_module(parts[0])) AttributeError: 'Import' object has no attribute 'infer_name_module'

Maybe astroid version 2.2.0 is incompabitl with pylint 2.2.2?

PCManticore commented 5 years ago

@jan11011977 Yeah, it looks like it! Can you try with pylint 2.3.0? This was released today as well.

jan11011977 commented 5 years ago

Yeah pylint 2.3.0 + astroid 2.2.0 works fine.

The reason we pin pylint is that new versions often introduce new types of errors, and we don't want our CI to break due to these new errors. For example 2.3.0 introduces a new "no-else-raise" error.

pdesgarets commented 5 years ago

Same issue here. Seems like the change commit is https://github.com/PyCQA/astroid/commit/51891dc8179a709bf18c7f2869ca32f2ec8a2e92 . A miss in reporting the breaking change in changelog + new major version ? Or is it supposed not to be part of the public API of astroid ?

PCManticore commented 5 years ago

@pdesgarets That's not a public API of astroid, which pylint unfortunately was relying on. Update to the latest and you'll be good to go.

mkorvas commented 4 years ago

I have observed the same exception message with the latest version of both Astroid and Pylint -- if anyone can confirm it's there, should it be tracked in a separate issue or do you prefer to continue discussing here?