Skip to content
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

[1.10] Regression with Any in functools.wraps() #17171

Open
Dreamsorcerer opened this issue Apr 25, 2024 · 1 comment
Open

[1.10] Regression with Any in functools.wraps() #17171

Dreamsorcerer opened this issue Apr 25, 2024 · 1 comment
Labels
bug mypy got something wrong

Comments

@Dreamsorcerer
Copy link
Contributor

Bug Report

We get an Any warning in 1.10:

aiojobs/aiohttp.py:50:5: error: Type of decorated function contains type "Any"
("_Wrapped[[_RequestView], Coroutine[object, object, _T], [_RequestView], Coroutine[Any, Any, _T]]")
 [misc]
        async def wrapper(request_or_view: _RequestView) -> _T:
        ^

It appears to me the problem is that the return type is inferred as Coroutine[Any, Any, _T]. Can't mypy infer this as Coroutine[None, None, _T] or atleast Coroutine[object, object, _T]?

To Reproduce

The code is:

def atomic(
    coro: Callable[[_RequestView], Coroutine[object, object, _T]]
) -> Callable[[_RequestView], Awaitable[_T]]:
    @wraps(coro)
    async def wrapper(request_or_view: _RequestView) -> _T:

https://github.com/aio-libs/aiojobs/blob/e204b06d801d538783bc902ffccf855a48ced0c2/aiojobs/aiohttp.py#L46-L61

@Dreamsorcerer Dreamsorcerer added the bug mypy got something wrong label Apr 25, 2024
@tmke8
Copy link
Contributor

tmke8 commented Apr 25, 2024

Just for reference, this is likely due to #16942.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants