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
Returning Any from function declared to return object #9590
Comments
We are also running into this when upgrading from mypy 0.782 to 0.790. It seems that |
The original issue reproes for me on v0.782 (and older), which suggests you're seeing something slightly different. Regressions are often easier to fix (if it is a regression), so would be useful if you could post a minimal repro of what you're seeing. |
Split off into #9656. |
I had a little dig through the code, and have found that the behaviour forks in When it evaluates the lambda in the second form (i.e. assigned to a variable), |
Another repro case: from typing import Any, Callable, TypeVar
T = TypeVar('T')
def producer() -> Any:
return 1
def call(callee: Callable[[], T]) -> T:
return callee()
call(lambda: producer())
Note that this only seems to fire with |
Also add a type ignore because of this mypy bug: python/mypy#9590
FWIW this works on current master (due to special-casing of |
Minimum test case:
Mypy outputs:
error: Returning Any from function declared to return "object" [no-any-return]
But, the error disappears if I change the code to:
Despite there being no more or less typing information here.
The text was updated successfully, but these errors were encountered: