-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix async iterator body stripping #15491
Conversation
for more information, see https://pre-commit.ci
and self.strip_function_bodies | ||
and len(stack) == 1 | ||
and stack[0] == "F" | ||
and not is_coroutine |
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.
We can strip if there is no yield
right? Also IIUC this is the actual fix, while the change below is just a refactoring, right?
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.
Change below isn't just refactoring, since the stripping below used to only happen in methods.
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.
OK, wait, but then now the stripping in last part will occur even if stack[0] != "F"
, is it safe?
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.
Added that check, and fixed a bug I introduced in the logic for empty bodies
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I added the reporting repo to primer and hit update branch, so hopefully diff will show up. |
Diff from mypy_primer, showing the effect of this PR on open source code: vision (https://github.com/pytorch/vision): typechecking got 1.28x slower (38.1s -> 48.9s)
(Performance measurements are based on a single noisy sample)
aiohttp-devtools (https://github.com/aio-libs/aiohttp-devtools)
- aiohttp_devtools/runserver/watch.py:70: error: "Coroutine[Any, Any, AsyncGenerator[set[tuple[Change, str]], None]]" has no attribute "__aiter__" (not async iterable) [attr-defined]
- aiohttp_devtools/runserver/watch.py:70: note: Maybe you forgot to use "await"?
- aiohttp_devtools/runserver/watch.py:147: error: "Coroutine[Any, Any, AsyncGenerator[set[tuple[Change, str]], None]]" has no attribute "__aiter__" (not async iterable) [attr-defined]
- aiohttp_devtools/runserver/watch.py:147: note: Maybe you forgot to use "await"?
|
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 fix!
Fixes #15489