pylint-dev/pylint

False positive: possibly-used-before-assignment and sys.exit()

mueller-ma opened this issue · 2 comments

Bug description

import sys

if True:
    x = 0
else:
    sys.exit(0)

print(x) # Reports possibly-used-before-assignment

Configuration

No response

Command used

pylint foo.py

Pylint output

************* Module foo
[Some unrelated messages]
foo.py:8:6: E0606: Possibly using variable 'x' before assignment (possibly-used-before-assignment)

Expected behavior

No error

Pylint version

pylint 3.2.0
astroid 3.2.2
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]

OS / Environment

No response

Additional dependencies

No response

Thank you for the triaging @mueller-ma 😄