Closed
Description
The undefined variable runners uses an undefined attributes __all__, pylint reports an inference failed. See the following example.
pylint_example.py
import sys
if sys.version_info >= (3, 7):
__all__ += runners.__all__
The expected behavior:
Pylint does not crash.
The actual output:
>> pylint pylint_example.py
************* Module pylint_example
Desktop/pylint_example.py:19:0: C0303: Trailing whitespace (trailing-whitespace)
Desktop/pylint_example.py:56:0: C0304: Final newline missing (missing-final-newline)
Desktop/pylint_example.py:1:0: C0114: Missing module docstring (missing-module-docstring)
Desktop/pylint_example.py:55:4: E0602: Undefined variable '__all__' (undefined-variable)
Desktop/pylint_example.py:55:15: E0602: Undefined variable 'runners' (undefined-variable)
Exception on node <Module.pylint_example l.0 at 0x7f797324d190> in file '/home/xxm/Desktop/pylint_example.py'
Traceback (most recent call last):
File "/home/xxm/.local/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 96, in walk
callback(astroid)
File "/home/xxm/.local/lib/python3.11/site-packages/pylint/checkers/variables.py", line 1364, in leave_module
self._check_all(node, not_consumed)
File "/home/xxm/.local/lib/python3.11/site-packages/pylint/checkers/variables.py", line 3049, in _check_all
assigned = next(node.igetattr("__all__"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxm/.local/lib/python3.11/site-packages/astroid/bases.py", line 197, in _infer_stmts
raise InferenceError(
astroid.exceptions.InferenceError: Inference failed for all members of [<AssignName.__all__ l.55 at 0x7f797324da10>].
Desktop/empirical_type_checker/bug_report/pylint_example.py:1:0: F0002: /home/xxm/Desktop/pylint_example.py: Fatal error while checking '/home/xxm/Desktop/pylint_example.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/home/xxm/.cache/pylint/pylint-crash-2023-06-07-00-29-01.txt'. (astroid-error)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
Test Environment:
Ubuntu 18.04,
CPython 3.11.3
Pylint: 3.0.0b1
astroid 3.0.0a3