Closed
Description
Bug description
I think we can raise a more appropriate message for cases like:
def type_annotation_used_improperly_after_comprehension():
"""https://github.com/PyCQA/pylint/issues/5654"""
my_int: int
_ = [print(sep=my_int, end=my_int) for my_int in range(10)] <--should be used-before-assignment
print(my_int) # [undefined-variable]
Because the python interpreter produces:
UnboundLocalError: local variable 'my_int' referenced before assignment
This feature was added in #5158, so perhaps recent enough to change, but not sure if it's too much churn/worth it to bother.
Expected behavior
Raise used-before-assignment
instead of unused-variable
for the above test from undefined_variable_py38.py
Pylint version
pylint 2.13.0-dev0
astroid 2.9.3
Python 3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-1300.0.29.3)]