-
Notifications
You must be signed in to change notification settings - Fork 159
Type error: Value of type variable "_R" of function cannot be "AsyncClient"
#1090
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
Comments
Thanks for reporting this! Could this be a regression of #1045? |
Yeah correct, that PR binds the "return" That assumption is incorrect because it's possible to wrap non- @pytest_asyncio.fixture
def some_int() -> int:
return 5 An alternate design could be @pytest.fixture
def some_int() -> int:
return 5 |
In my opinion, pytest-asyncio should raise an error when the user tries to decorate synchronous tests with That said, we cannot simply error out in this case. We should first raise a DeprecationWarning to give users a chance to update their code. A later release can turn the warning into an error. |
This is not limited to wrapping non-async functions. I'm also seeing this kind of error when wrapping an import asyncio
from typing import AsyncIterable
import pytest_asyncio
@pytest_asyncio.fixture(scope="session")
async def dummy_fixture() -> AsyncIterable[str]:
await asyncio.sleep(1)
yield "dummy" Running mypy on this code produces:
|
pytest-asyncio==0.26.0
with: Value of type variable "_R" of function cannot be "AsyncClient"
Value of type variable "_R" of function cannot be "AsyncClient"
Upgrading to
pytest-asyncio==0.26.0
:I get this error from
mypy
:This is with Python 3.12.7 and the following packages:
The text was updated successfully, but these errors were encountered: