-
Notifications
You must be signed in to change notification settings - Fork 769
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
Code should not be marked as unreachable in certain situations #473
Comments
A type checker needs to be told that your context manager can handle exceptions. Most of them do not. Type checkers (including mypy and pyright/pylance) have adopted a convention whereby if the |
Annotate Moreover, the same code has no issues in PyCharm |
Sorry, the thread I referenced said Here's another simple workaround for your particular case. You can provide a def dangerous() -> None:
raise FakeException |
You are right, annotating it with |
Environment data
python.languageServer
setting: PylanceExpected behaviour
The code should not be marked as unreachable when it is perfectly reachable
Actual behaviour
As you can see, the above code is marked as unreachable just because
dangerous
raises an exception.I am justly testing that stack.capture() captures the exception. I think is not correct to mark the code as unreachable when there is a context manager that can handle the exception.
The text was updated successfully, but these errors were encountered: