Open
Description
Bug description
This doesn't warn as it should:
try:
pass
except ValueError:
msg = 'ha'
print(msg)
print(msg) # should raise used-before-assignment
But this warns just fine:
try:
pass
except ValueError:
msg = 'ha'
print(msg) # [used-before-assignment]
So it's an issue with "consuming" the name too early in the variables checker when used by the first "print(msg)".
Configuration
No response
Command used
pylint a.py
Pylint output
-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 1.67/10, +8.33)
Expected behavior
************* Module a
a.py:6:6: E0601: Using variable 'msg' before assignment (used-before-assignment)
Pylint version
pylint 2.13.0-dev0
astroid 2.9.2
Python 3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-1300.0.29.3)]
OS / Environment
No response
Additional dependencies
No response