-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add await to empty context hack #19777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add await to empty context hack #19777
Conversation
(and confirmed that I'm surprised that this was the only problem caused by stub definitions. I'll open a follow-up PR to sync variance in other |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch! I have one suggestion.
if isinstance(s.expr, (CallExpr, ListExpr, TupleExpr, DictExpr, SetExpr, OpExpr)): | ||
if isinstance( | ||
s.expr, (CallExpr, ListExpr, TupleExpr, DictExpr, SetExpr, OpExpr, AwaitExpr) | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using isinstance(s.expr, AwaitExpr) and isinstance(s.expr.expr, CallExpr)
? This will save us some pointless busy-work for cases like return await some_name
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, yes, makes sense. I doubt that await not_a_call
accounts for some significant portion of await
expressions, but this shouldn't harm.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #19716. It is a follow-up to #19767 and was missed there due to malformed test stubs (the same testcase fails when run by full mypy against typeshed, I did not notice missing AwaitExpr because of the passing test...). I synced typevar variance with typeshed definitions and added AwaitExpr to the list of context-dependent exprs. Cc @ilevkivskyi