Open gothicVI opened 1 day ago
Removing the redundant assertions
file_handle = mock_open_func()
file_handle.write.assert_called_once_with(outputstring)
makes the error go away.
Have you tried on the latest versions of pylint and astroid?
Bug description
The file is saved as
tests/test__auth
where the module is located insrc/package/
When parsing the following
a.py
:Command used
Pylint output
pylint crashed with a ``AstroidError`` and with the following stacktrace:
```python Traceback (most recent call last): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 90, in inner yield next(generator) ^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/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 "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/lint/pylinter.py", line 788, in _lint_file check_astroid_module(module) File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/lint/pylinter.py", line 1017, in check_astroid_module retval = self._check_astroid_module( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/lint/pylinter.py", line 1069, in _check_astroid_module walker.walk(node) File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/utils/ast_walker.py", line 94, in walk self.walk(child) File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/utils/ast_walker.py", line 94, in walk self.walk(child) File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/utils/ast_walker.py", line 94, in walk self.walk(child) [Previous line repeated 1 more time] File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/utils/ast_walker.py", line 91, in walk callback(astroid) File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/checkers/base/basic_checker.py", line 713, in visit_call if utils.is_terminating_func(node): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/checkers/utils.py", line 2160, in is_terminating_func for inferred in node.func.infer(): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_ng.py", line 169, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 103, in inner yield from generator File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 49, in wrapped for res in _func(node, context, **kwargs): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_classes.py", line 1090, in _infer_attribute for owner in node.expr.infer(context): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_ng.py", line 169, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 103, in inner yield from generator File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 49, in wrapped for res in _func(node, context, **kwargs): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_classes.py", line 1090, in _infer_attribute for owner in node.expr.infer(context): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_ng.py", line 169, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 103, in inner yield from generator File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 49, in wrapped for res in _func(node, context, **kwargs): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/bases.py", line 179, in _infer_stmts for inf in stmt.infer(context=context): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_ng.py", line 169, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 103, in inner yield from generator File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 49, in wrapped for res in _func(node, context, **kwargs): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/bases.py", line 179, in _infer_stmts for inf in stmt.infer(context=context): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_ng.py", line 169, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 103, in inner yield from generator File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 49, in wrapped for res in _func(node, context, **kwargs): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_classes.py", line 1765, in _infer yield from callee.infer_call_result( File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/bases.py", line 331, in infer_call_result for res in node.infer_call_result(caller, context): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/bases.py", line 331, in infer_call_result for res in node.infer_call_result(caller, context): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/bases.py", line 331, in infer_call_result for res in node.infer_call_result(caller, context): [Previous line repeated 922 more times] File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/bases.py", line 328, in infer_call_result for node in self._proxied.igetattr("__call__", context): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2511, in igetattr inferred._proxied.getattr("__get__", context) File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2415, in getattr values += self._metaclass_lookup_attribute(name, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2439, in _metaclass_lookup_attribute attrs.update(set(cls_attributes)) ^^^^^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/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/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2415, in getattr values += self._metaclass_lookup_attribute(name, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2435, in _metaclass_lookup_attribute metaclass = self.metaclass(context=context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2727, in metaclass return self._find_metaclass(context=context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2707, in _find_metaclass klass = self.declared_metaclass(context=context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2679, in declared_metaclass for baseobj in base.infer(context=context): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/nodes/node_ng.py", line 169, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/astroid/decorators.py", line 99, in inner raise InferenceError( ^^^^^^^^^^^^^^^ RecursionError: maximum recursion depth exceeded The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/lint/pylinter.py", line 752, in _lint_files self._lint_file(fileitem, module, check_astroid_module) File "/home/user/.vscodium-server/extensions/ms-python.pylint-2023.10.1/bundled/libs/pylint/lint/pylinter.py", line 790, in _lint_file raise astroid.AstroidError from e astroid.exceptions.AstroidError ```Expected behavior
No crash.
Pylint version
OS / Environment
linux (Linux) VSCodium 1.93.1 Pylint plugin v2023.10.1
Additional dependencies
The module to be testes reads
src/package/_auth.py