-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Pyright does not handle NoReturn in async await #2598
Comments
Same happens with generators too: # pyright: strict
from typing import Generator, NoReturn
def func() -> Generator[int, None, NoReturn]:
c = 0
while True:
c += 1
yield c
def main() -> NoReturn:
for i in func():
print(i)
# <--- This will never execute
main() |
I've fixed the issue with async functions. I'm not convinced the second one is valid though. The |
If that's the case then why in async function the type can be |
|
It still looks wrong to me that |
This is included in pyright 1.1.190, which I just published. It will also be included in the next release of pylance. |
Hi Guys , You can create a asyncio.create_task and await that task. With this the Pyright does not throw <"NoReturn" is not awaitable>. response = asyncio.create_task( awaitable ). Below is an example I solved for aioboto3 for sqs polling :
|
Note: if you are reporting a wrong signature of a function or a class in the standard library, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues.
Describe the bug
Pyright does not handle NoReturn in async await
Expected behavior
No error.
Screenshots or Code
If applicable, add screenshots or the text of the code (surrounded by triple back ticks) to help explain your problem.
VS Code extension or command-line
Are you running pyright as a VS Code extension or a command-line tool? Which version? You can find the version of the VS Code extension by clicking on the Pyright icon in the extensions panel.
pyright 1.1.189
The text was updated successfully, but these errors were encountered: