-
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
Coroutine[Any, Any, None] is not awaitable #9204
Comments
I'm not able to repro the problem you're reporting. Code sample in pyright playground Can you please verify that if you paste your code sample into a new project with a fresh venv that you get the same behavior? Is it possible that you have a local module named |
I have the same issue, also in Zed. However I don't have it when I run my homebrew installed pyright on the same code, so might be something with the version in Zed? |
@tino Also in Zed, have you fixed this? |
I have the exact same problem. All asynchronous function calls will randomly report errors or not, even if you don't change anything |
Also reporting a similar issue. Either all the Python version 3.12.5, I saw some correlation with import nest_asyncio
nest_asyncio.apply() But it is not a 100% reproducible behavior. I might suspect something to do with it though, given its monkey-patchiness |
Thanks for the additional clues. These are helpful, so keep them coming! Is this behavior something that started recently? If so, that would point to a recent code change as the cause. If you restart the language server, does the problem go away? Are you able to repro the problem with the command-line version of pyright? Does anyone have a consistent repro, or is it always intermittent and nondeterministic? |
Yes. This is very recent. I just rolled back to
No, I've also tried developer: reload, clear python cache and reload and pylance: clear persisted indices.
No dice. |
Yes, it just randomly happens.
The issue happens in this recent week and there're tons of errors in my projects. |
thank god I found this issue, this drove me crazy the last three days |
When you say "these kinds of errors", are you referring specifically to the "Coroutine[Any, Any, None] is not awaitable" error, or are there other errors you're seeing? In the absence of a solid repro, I'm trying to establish some pattern, so any clues you can provide are welcome. |
Basically, I mean |
For me, "these kinds of errors" are
I had 0 of them before, now I have 539 of them. |
Thanks for the info. When you say "before", do you remember which version you were using? Has anyone seen the problem with the command-line version of pyright, or is this only with the language server? I just published version 1.1.385 of pyright to npm. It should be published to pypi in the next 24 hours. The last two errors in your list above are likely addressed by the new version, but I don't think the first two errors will be. |
I don't remember since Zed automatically download and update |
@erictraut this issue still persist with pyright version |
I have this issue in vscode with Pylance v2024.10.100 (pre-release) |
I am seeing this exact same issue in Neovim using pyright installed via Homebrew on my M1 Mac:
This just started for me about a week or so ago. These errors around async functions seemingly appear and disappear at random. My project is using Poetry with a local virtualenv at [tool.pyright]
exclude = [".venv", "build", "dist"]
venvPath = "."
venv = ".venv" Many errors like this one: |
Also reporting this problem, specifically after I save or run my linter. The errors go away after editing the file (but not saving).
Example diagnostic text:
|
+1, also zed, literally same looking errors as others have reported |
In case it helps, I'm seeing what is probably the same regression, but the reported errors are about assignments of string literals to parameters of type
This is on Python 3.12.1, with pyright versions 1.1.384 and 1.1.385. Version 1.1.383 does not show these errors. |
Thanks to everyone for the clues. Unfortunately, I haven't been able to find a repro, and I'm running short on theories at this point. I've tried to repro using a bunch of large open-source code bases that make heavy use of Are any of you able to repro this with a source base that is publicly accessible in GitHub? @trendels, you mentioned that you're seeing an error with |
I don't think the problem seems to be how big the repo is, as issuse suggests, it can be a problem on a very short example, anyway, I'm glad there won't be any problems on pyright 1.1.383 |
I think it's related to Here's some self-contained code that will show the error on my machine: import openai
import nest_asyncio
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from openai.types import chat
nest_asyncio.apply() # pyright: ignore[reportUnknownMemberType]
async def complete(prompt: str) -> str:
client = openai.AsyncOpenAI(
base_url="",
)
message: chat.chat_completion_message_param.ChatCompletionMessageParam = {
"role": "user",
"content": prompt,
}
response = await client.chat.completions.create(
model="MY_MODEL",
messages=[message],
)
return str(response.choices[0].message.content) I'm going to attach a mock repo that contains this code and errors. I initialized via https://docs.astral.sh/uv/ with
|
…ften relating to the "awaitable" check. This addresses #9204.
@BaconPancakes, thanks for taking the time to put together those repro steps. I really appreciate it. It took me a while to get a repro, even with your detailed instructions, but I eventually got it to happen. This allowed me to find and fix the underlying cause. The underlying bug was introduced a few years ago (relating to special-case handling of Thanks everyone for your help in providing clues. Apologies for the regression and the inconvenience this caused. This will be addressed in the next release. |
This is addressed in pyright 1.1.386 |
Version:
1.1.384
The text was updated successfully, but these errors were encountered: