-
Notifications
You must be signed in to change notification settings - Fork 262
Open
Copy link
Labels
narrowingIssues with narrowing - root cause is usually narrowing, flow handling, or bothIssues with narrowing - root cause is usually narrowing, flow handling, or bothtypechecking
Description
Describe the Bug
Consider:
options: dict[str, str] = {}
if 'contains' in options:
ingredients = [x.strip() for x in options.get('contains').split(',')]options is known to have the key 'contains' in the branch given the explicit check, so options.get('contains') will have type VT (here str) not None. pyrefly currently reports an error, though.
I don't believe any type checker currently recognises this, so no objections to this being closed as out of scope, but I thought worth raising the question.
A
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Sub-issues
Metadata
Metadata
Assignees
Labels
narrowingIssues with narrowing - root cause is usually narrowing, flow handling, or bothIssues with narrowing - root cause is usually narrowing, flow handling, or bothtypechecking