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

Support try/except in partially defined check #13928

Closed
ilinum opened this issue Oct 20, 2022 · 2 comments · Fixed by #14114
Closed

Support try/except in partially defined check #13928

ilinum opened this issue Oct 20, 2022 · 2 comments · Fixed by #14114
Labels
feature topic-possibly-undefined possibly-undefined error code

Comments

@ilinum
Copy link
Collaborator

ilinum commented Oct 20, 2022

Currently, partially defined check (--enable-error-code partially-defined) does not support detecting partially defined variables try/except statement.

The most basic example is the following:

try:
  x = foo()
except:
  pass
y = x  # mypy should generate an error here but does not.
@ilevkivskyi
Copy link
Member

@ilinum What is the situation here? I see there were no activity on the PR last week. We will probably start 1.0 release process in a week or so. I would like to announce this feature in the release, and it would be great if try/except is properly supported.

@JukkaL
Copy link
Collaborator

JukkaL commented Dec 9, 2022

I can do another round of review and make some performance measurements.

ilinum added a commit that referenced this issue Dec 16, 2022
This adds support for try/except/finally/else check.

The implementation ended up pretty complicated because it had to handle
jumps different for finally. It took me a few iterations to get to this
solution and that's the cleanest one I could come up with.

Closes #13928.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature topic-possibly-undefined possibly-undefined error code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants