-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed as not planned
Labels
Duplicate 🐫Duplicate of an already existing issueDuplicate of an already existing issue
Description
Bug description
When parsing a file that looks like following (I can't give you the complete code) a.py:
import unittest
from typing import Final
import torch
INPUT_SHAPE: Final[tuple[int, ...]] = (1, 3, 8, 8)
INPUT: Final[torch.Tensor] = torch.ones(INPUT_SHAPE)
class TestLayer(unittest.TestCase):
def test_returns_same_dtype_as_input(self) -> None:
reduced_precision_input = INPUT.to(torch.float16)
layer = ...
layer_output = layer(reduced_precision_input)
self.assertEqual(layer_output.output.dtype, torch.float16) # <- inclusion of this line causes the errorCommand used
pylint a.pyPylint output
pylint crashed with a ``AstroidError`` and with the following stacktrace:
Traceback (most recent call last):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 90, in inner
yield next(generator)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 44, in wrapped
if context.push(node):
RecursionError: maximum recursion depth exceeded
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/checkers/utils.py", line 1370, in safe_infer
for inferred in infer_gen:
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/node_classes.py", line 1090, in _infer_attribute
for owner in node.expr.infer(context):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
for inf in stmt.infer(context=context):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
for inf in stmt.infer(context=context):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 103, in inner
yield from generator
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/node_classes.py", line 1764, in _infer
yield from callee.infer_call_result(
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/bases.py", line 329, in infer_call_result
for res in node.infer_call_result(caller, context):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/bases.py", line 329, in infer_call_result
for res in node.infer_call_result(caller, context):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/bases.py", line 329, in infer_call_result
for res in node.infer_call_result(caller, context):
[Previous line repeated 943 more times]
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/bases.py", line 326, in infer_call_result
for node in self._proxied.igetattr("__call__", context):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2524, in igetattr
inferred._proxied.getattr("__get__", context)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2428, in getattr
values += self._metaclass_lookup_attribute(name, context)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2452, in _metaclass_lookup_attribute
attrs.update(set(cls_attributes))
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2459, in _get_attribute_from_metaclass
attrs = cls.getattr(name, context=context, class_context=True)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2428, in getattr
values += self._metaclass_lookup_attribute(name, context)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2448, in _metaclass_lookup_attribute
metaclass = self.metaclass(context=context)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2740, in metaclass
return self._find_metaclass(context=context)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2720, in _find_metaclass
klass = self.declared_metaclass(context=context)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2692, in declared_metaclass
for baseobj in base.infer(context=context):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/nodes/node_ng.py", line 170, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/decorators.py", line 99, in inner
raise InferenceError(
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/astroid/exceptions.py", line 272, in __init__
super().__init__(message, **kws)
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 "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 787, in _lint_file
check_astroid_module(module)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 1016, in check_astroid_module
retval = self._check_astroid_module(
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 1068, in _check_astroid_module
walker.walk(node)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 94, in walk
self.walk(child)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 94, in walk
self.walk(child)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 94, in walk
self.walk(child)
[Previous line repeated 4 more times]
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 91, in walk
callback(astroid)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/checkers/deprecated.py", line 94, in visit_attribute
self.check_deprecated_attribute(node)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/checkers/deprecated.py", line 215, in check_deprecated_attribute
inferred_expr = safe_infer(node.expr)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/checkers/utils.py", line 1392, in safe_infer
raise AstroidError from e
astroid.exceptions.AstroidError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 751, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "/Users/ringo/anaconda3/envs/core310/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 789, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidErrorExpected behavior
No crash.
Pylint version
pylint 3.1.0
astroid 3.1.0
Python 3.10.12 (main, Jul 5 2023, 15:02:25) [Clang 14.0.6 ]OS / Environment
darwin (Darwin)
Additional dependencies
torch
Metadata
Metadata
Assignees
Labels
Duplicate 🐫Duplicate of an already existing issueDuplicate of an already existing issue