-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
false unreachable error after pytest.raises block #8985
Comments
Mypy by default assumes context managers don't suppress exceptions, because that's more common in general. See https://github.com/python/typeshed/blob/master/CONTRIBUTING.md#conventions (second to last paragraph) and #7214 (comment). To fix this issue |
@JelleZijlstra yeah, this is unfortunate though, because for an un-annotated library (like pytest) there is no way for a user to change mypy's behavior here. Perhaps we should default to context managers that are |
@ethanhs that would also cause false positives (about missing return statements). |
@JelleZijlstra yes but those false positives can be silenced via asserts. I think it is better to have false positives that can be disabled. Furthermore, incorrectly calling a branch dead could lead to false negatives. |
pytest 6 is going to have published type annotations, hopefully (link), though we're still working on the details. |
I'm happy to confirm that this is fixed with pytest-dev/pytest#7448. Thanks again for your work on this @bluetech! :) |
Hi. mypy returns an unreachable error for code after a
pytets.raises
block:I'm actually not sure if this is a bug in mypy, since it might not be aware that pytest swallows the exception there. Any advice appreciated!
The text was updated successfully, but these errors were encountered: