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.33k stars 1.14k forks source link

Checking crashed #8798

Closed TheVroum closed 1 year ago

TheVroum commented 1 year ago

Bug description

Thank you for the effort you put in pylint !

Fatal error while checking (exception raised in astroid, and pylint crashing).

Have a good day/evening.

Configuration

No response

Command used

unkown (default automatic linting of vscode using pylint)
mypy is also used, together with autopep8 for formatting

Pylint output

crashed

First, please verify that the bug is not already filled:
https://github.com/PyCQA/pylint/issues/

Then create a new crash issue:
https://github.com/PyCQA/pylint/issues/new?assignees=&labels=crash%2Cneeds+triage&template=BUG-REPORT.yml

Issue title:
Crash ` (if possible, be more specific about what made pylint crash)
Content:
When parsing the following file:

<!--
 If sharing the code is not an option, please state so,
 but providing only the stacktrace would still be helpful.
 -->

"""current tester"""
import working
# from working.lexer_parser import Node
# from working.lexer_parser import Node

with open("samples_to_sort/sample1.txt", "r", encoding="utf-8") as content_file:
    content = content_file.read()

with open("grammar_w_errs.lark", "r", encoding="utf-8") as grammar_file:
    grammar = grammar_file.read()

tree = Node.from_evv_str(content, grammar)

pylint crashed with a AstroidError and with the following stacktrace:

Traceback (most recent call last):
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\lint\pylinter.py", line 798, in _lint_file
    check_astroid_module(module)
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\lint\pylinter.py", line 1067, in check_astroid_module
    retval = self._check_astroid_module(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\lint\pylinter.py", line 1117, in _check_astroid_module
    walker.walk(node)
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\utils\ast_walker.py", line 94, in walk
    self.walk(child)
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\utils\ast_walker.py", line 94, in walk
    self.walk(child)
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\utils\ast_walker.py", line 91, in walk
    callback(astroid)
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\checkers\base\basic_checker.py", line 705, in visit_call
    if utils.is_terminating_func(node):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\checkers\utils.py", line 2181, in is_terminating_func
    return True
           ^^^^
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\astroid\nodes\node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\astroid\decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\astroid\decorators.py", line 119, in wrapped
    yielded.add(ares)
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\astroid\inference.py", line 380, in infer_attribute
    context.boundnode = old_boundnode
    ^^^^^^^^^^^^^^^^^
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\astroid\nodes\node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\astroid\decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\astroid\decorators.py", line 111, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\astroid\inference.py", line 240, in infer_name
    raise NameInferenceError(
astroid.exceptions.NameInferenceError: 'Node' not found in <Module.tester l.0 at 0x1b9c0e378f0>.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\lint\pylinter.py", line 763, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File "c:\Users\anonymised\.vscode\extensions\ms-python.pylint-2023.4.0\bundled\libs\pylint\lint\pylinter.py", line 800, in _lint_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError

### Expected behavior

not crash

### Pylint version

```shell
python 3.12
pylint-2023.4.0

OS / Environment

Windows 11 /vscode/python 3.12 with multiple python version installed virtual environment is activated in terminal and selected on vscode pyton extension (3.12)

Additional dependencies

mypy==1.3.0 mypy-extensions==1.0.0 typing_extensions==4.6.3

jacobtylerwalls commented 1 year ago

Looks like a duplicate of #8695 (upstream CPython issue), but please reopen if you can reproduce on a more recent version of Python 3.12. Thanks.