Back to Intellij Community

PyUnboundLocalVariableInspection

python/python-psi-impl/resources/inspectionDescriptions/PyUnboundLocalVariableInspection.html

2025.3-rc-2223 B
Original Source

Reports local variables referenced before assignment.

Example:

x = 0
if x > 10:
    b = 3
print(b)

The IDE reports a problem for print(b). A possible fix is:

x = 0
if x > 10:
    b = 3
    print(b)