Pyright: Code marked `unreachable` after untyped lambda raising an exception.

Created on 18 Jun 2020  路  2Comments  路  Source: microsoft/pyright

Describe the bug
Code after lambda declaration with untyped function raising an exception is incorrectly marked as unreachable.

To Reproduce
Consider this piece of code

def dummy():
    def error():
        raise Exception

    x = lambda: error()

    print("Hello World")  # This is marked as unreachable code


dummy()

However, this problem does not appear if -> None is added to the error() signature.

Expected behavior
Code shouldn't be marked as unreachable.

Additional context

  • VS Code extension: - 1.1.43

    • settings:

      json { "pyright.typeCheckingMode": "strict", "pyright.useLibraryCodeForTypes": true }

  • Python: 3.8.3
addressed in next version bug

All 2 comments

Thanks for the bug report. This will be fixed in the next published version of Pyright.

This is now fixed in version 1.1.44, which I just published.

Was this page helpful?
0 / 5 - 0 ratings