Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not warn about "Uninitialized local [61]" if the program calls exit() before using the variable. #737

Open
jp-berg opened this issue May 22, 2023 · 0 comments

Comments

@jp-berg
Copy link

jp-berg commented May 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant