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

Contextlib.suppress confuses pylance "Code is unreachable" #559

Closed
fried opened this issue Nov 3, 2020 · 1 comment
Closed

Contextlib.suppress confuses pylance "Code is unreachable" #559

fried opened this issue Nov 3, 2020 · 1 comment

Comments

@fried
Copy link

fried commented Nov 3, 2020

Environment data

Language Server version: 2020.10.3
OS and version: macOS Catalina 10.15.7
Python version: 3.9.0 (installed via homebrew)

Expected behaviour

https://docs.python.org/3/library/contextlib.html#contextlib.suppress

Actual behaviour

Pylance says the code is unreachable

Code Snippet / Additional information

This example is contrived, but its a simplification I was testing some nested transaction context handlers.
And was supprised that pylance told me the code was unreachable on line 14.

Screen Shot 2020-11-03 at 10 37 22 AM

import unittest
from contextlib import suppress

class TransactionError(Exception):
    pass

class TestSomething(unittest.TestCase):
    def test_something(self):
        with suppress(TransactionError):
            raise TransactionError
        self.assertTrue(True)   ### HERE this is grey for being unreachable
@github-actions github-actions bot added the triage label Nov 3, 2020
@judej
Copy link
Contributor

judej commented Nov 3, 2020

Dupe of #494

@judej judej closed this as completed Nov 3, 2020
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

2 participants