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
https://pyrefly.org/sandbox/?code=PYBwLglsB2DOBcACAJhAxmA2rMAnANIjrgLqIC8iA3gL4BQEAZogORoxgCGEcLiPiUJBgI6icf2gBzXAFNUs6GFgVEmAB4A6YhBAAKAJSJGwXInWTB4KHE1TZYPWw7deB7SAA2ERy3wsDEjogA
(Only applicable for extension issues) IDE Information
No response
Describe the Bug
Consider:
optionsis known to have the key'contains'in the branch given the explicit check, sooptions.get('contains')will have typeVT(herestr) notNone.pyreflycurrently 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
https://pyrefly.org/sandbox/?code=PYBwLglsB2DOBcACAJhAxmA2rMAnANIjrgLqIC8iA3gL4BQEAZogORoxgCGEcLiPiUJBgI6icf2gBzXAFNUs6GFgVEmAB4A6YhBAAKAJSJGwXInWTB4KHE1TZYPWw7deB7SAA2ERy3wsDEjogA
(Only applicable for extension issues) IDE Information
No response