-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
Description
Describe the bug
Not important as such in any specific case but wanted to report.
While pyright detects that a section of code is unreachable it still uses these statements for type inference of a variable.
Code or Screenshots
In the following code pyright excludes the possibility of a=5 since it detects the overwrite later but it has also marked that code as unreachable
# pyright: strict
from typing import Any, Literal
from typing_extensions import assert_type, Never
def no_return() -> Never:
raise Exception()
class CtxMgr:
def __enter__(self):
return self
def __exit__(self, *exc_info: Any) -> bool:
return True
a = None
with CtxMgr():
a = 5
no_return()
a = 10
assert a is not None
assert_type(a, Literal[5])VS Code extension or command-line
Pylance language server 2023.12.1 (pyright a78e2b1)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
