-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Changes how unreachable statements are detected, refs #11437 #11443
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall idea seems good, but I think that there may be various tweaks that could make this even better.
|
||
def second() -> NoReturn: | ||
raise Exception | ||
raise Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this should be treated as unreachable code as well. Maybe the empty statement check for the following statements should be stricter, so that only pass
, ...
and maybe reveal_type(...)
would be considered as empty, and maybe asserts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the initial motivation was to allow some "debug" code to reduce the number of false positives. For example, I can see some cases where people would use code like:
assert False, 'unreachable'
raise RuntimeError('should not be reached')
sys.exit(1) # should not be reached
Closes #11437
I suspect that some
mypy
/mypy_primer
tests can fail after this change.But, it looks logical and consistent to me.