pyre-check
pyre-check copied to clipboard
Do not warn about "Uninitialized local [61]" if the program calls exit() before using the variable.
Pyre Feature Request
Is your feature request related to a problem? Please describe.
Pyre seems to lack understanding of the exit()-keyword. If I try to initialize a variable v and exit the program if the initialization fails, I do not want pyrex to complain that v "is undefined, or not always defined." (Uninitialized local [61])
Describe the solution you'd like Pyre should not warn about "Uninitialized local [61]" if the program exits in case the variable is not initialized.
Describe alternatives you've considered -
Additional context
Examples where I would like pyre to not warn about "Uninitialized local [61]" with regards to "v":
try:
v = initV()
except InitError as e:
print("Could not initialize v", e, file=sys.stderr)
exit(ERRORCODE)
return v
if x_is_right_for_v(x):
v = x
else:
print(f"{x=} does not work for v")
exit(ERRORCODE)
do_useful_stuff(v)
I recon that this type of pattern can be common when initializing the Python-application and something goes critically wrong, but I am still inexperienced, so this may be a bad pattern alltogether.