Closed as not planned
Closed as not planned
Description
Bug description
### Bug description
Crash when running Pylint on PyTorch using code (proprietary, can't share)
### Command used
pylint
### Pylint output
pylint crashed with a ``AstroidError`` and with the following stacktrace:
```python
Exception on node <Subscript l.80 at 0x7ff55c93a3a0> in file '/home/reuben/dev/REDACTED.py'
Traceback (most recent call last):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/checkers/utils.py", line 1370, in safe_infer
for inferred in infer_gen:
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 179, in _infer_stmts
for inf in stmt.infer(context=context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 179, in _infer_stmts
for inf in stmt.infer(context=context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 1765, in _infer
yield from callee.infer_call_result(
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 331, in infer_call_result
for res in node.infer_call_result(caller, context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 331, in infer_call_result
for res in node.infer_call_result(caller, context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 331, in infer_call_result
for res in node.infer_call_result(caller, context):
[Previous line repeated 947 more times]
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 328, in infer_call_result
for node in self._proxied.igetattr("__call__", context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2511, in igetattr
inferred._proxied.getattr("__get__", context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2415, in getattr
values += self._metaclass_lookup_attribute(name, context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2439, in _metaclass_lookup_attribute
attrs.update(set(cls_attributes))
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2446, in _get_attribute_from_metaclass
attrs = cls.getattr(name, context=context, class_context=True)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2415, in getattr
values += self._metaclass_lookup_attribute(name, context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2435, in _metaclass_lookup_attribute
metaclass = self.metaclass(context=context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2727, in metaclass
return self._find_metaclass(context=context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2709, in _find_metaclass
for parent in self.ancestors(context=context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2239, in ancestors
with context.restore_path():
File "/home/reuben/.pyenv/versions/3.8.10/lib/python3.8/contextlib.py", line 240, in helper
return _GeneratorContextManager(func, args, kwds)
File "/home/reuben/.pyenv/versions/3.8.10/lib/python3.8/contextlib.py", line 86, in __init__
doc = getattr(func, "__doc__", None)
RecursionError: maximum recursion depth exceeded while calling a Python object
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 91, in walk
callback(astroid)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/checkers/typecheck.py", line 2107, in visit_subscript
self._check_invalid_sequence_index(node)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/checkers/typecheck.py", line 1693, in _check_invalid_sequence_index
parent_type = safe_infer(subscript.value)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/checkers/utils.py", line 1392, in safe_infer
raise AstroidError from e
astroid.exceptions.AstroidError
Expected behavior
No crash.
Pylint version
pylint 3.0.3
astroid 3.0.3
Python 3.8.10 (default, Feb 19 2024, 14:10:39)
[GCC 9.4.0]
OS / Environment
linux (Linux)
Additional dependencies
torch 1.12.1
### Configuration
_No response_
### Command used
```shell
python -m pylint
Pylint output
Exception on node <Subscript l.80 at 0x7ff55c93a3a0> in file '/home/reuben/dev/REDACTED.py'
Traceback (most recent call last):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/checkers/utils.py", line 1370, in safe_infer
for inferred in infer_gen:
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 179, in _infer_stmts
for inf in stmt.infer(context=context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 179, in _infer_stmts
for inf in stmt.infer(context=context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 1765, in _infer
yield from callee.infer_call_result(
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 331, in infer_call_result
for res in node.infer_call_result(caller, context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 331, in infer_call_result
for res in node.infer_call_result(caller, context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 331, in infer_call_result
for res in node.infer_call_result(caller, context):
[Previous line repeated 947 more times]
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/bases.py", line 328, in infer_call_result
for node in self._proxied.igetattr("__call__", context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2511, in igetattr
inferred._proxied.getattr("__get__", context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2415, in getattr
values += self._metaclass_lookup_attribute(name, context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2439, in _metaclass_lookup_attribute
attrs.update(set(cls_attributes))
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2446, in _get_attribute_from_metaclass
attrs = cls.getattr(name, context=context, class_context=True)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2415, in getattr
values += self._metaclass_lookup_attribute(name, context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2435, in _metaclass_lookup_attribute
metaclass = self.metaclass(context=context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2727, in metaclass
return self._find_metaclass(context=context)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2709, in _find_metaclass
for parent in self.ancestors(context=context):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2239, in ancestors
with context.restore_path():
File "/home/reuben/.pyenv/versions/3.8.10/lib/python3.8/contextlib.py", line 240, in helper
return _GeneratorContextManager(func, args, kwds)
File "/home/reuben/.pyenv/versions/3.8.10/lib/python3.8/contextlib.py", line 86, in __init__
doc = getattr(func, "__doc__", None)
RecursionError: maximum recursion depth exceeded while calling a Python object
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 91, in walk
callback(astroid)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/checkers/typecheck.py", line 2107, in visit_subscript
self._check_invalid_sequence_index(node)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/checkers/typecheck.py", line 1693, in _check_invalid_sequence_index
parent_type = safe_infer(subscript.value)
File "/home/reuben/.local/share/virtualenvs/REDACTED/lib/python3.8/site-packages/pylint/checkers/utils.py", line 1392, in safe_infer
raise AstroidError from e
astroid.exceptions.AstroidError
Expected behavior
No crash
Pylint version
pylint 3.0.3
astroid 3.0.3
Python 3.8.10 (default, Feb 19 2024, 14:10:39)
[GCC 9.4.0]
OS / Environment
Ubuntu 20.04
Additional dependencies
torch==1.12.1