-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
tyMulti-file analysis & type inferenceMulti-file analysis & type inference
Description
We currently support type narrowing on various kinds of expressions in a test clause, e.g.
x = 1 if flag() else None
reveal_type(x) # revealed: Literal[1] | None
if x is not None:
reveal_type(x) # revealed: Literal[1]This task is to add support for the case where the test expression is wrapped in an explicit call to bool(...), e.g. if bool(x is not None):. This is not a common pattern, but pyright supports it, it's always correct, and it's not hard to implement, so there's little reason not to support it.
For any test expression E which we would draw narrowing conclusions from, we should draw the same conclusions from the test expression bool(E).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
tyMulti-file analysis & type inferenceMulti-file analysis & type inference