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

Never is inferred in combination with generics and partial #16540

Closed
rggjan opened this issue Nov 22, 2023 · 1 comment
Closed

Never is inferred in combination with generics and partial #16540

rggjan opened this issue Nov 22, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@rggjan
Copy link

rggjan commented Nov 22, 2023

Not sure if this is related / the same issue as #16522, but the following code doesn't work in mypy 1.7.0:

from functools import partial
from typing import TypeVar, Optional


E = TypeVar("E")


def foo(x: E, y: E) -> Optional[E]:
    print(x)
    return y


bar = partial(foo, 3) # error: Argument 1 to "partial" has incompatible type "Callable[[E, E], Optional[E]]"; expected "Callable[..., Never]"  [arg-type]
print(bar(4))

whereas it worked fine in mypy 1.4.1.

I believe the code and typing are correct, though?

It also works fine when returning E instead of Optional[E] in both versions.

@rggjan rggjan added the bug mypy got something wrong label Nov 22, 2023
@rggjan rggjan changed the title Never in inferred in combination with generics Never is inferred in combination with generics Nov 22, 2023
@rggjan rggjan changed the title Never is inferred in combination with generics Never is inferred in combination with generics and partial Nov 22, 2023
@ilevkivskyi
Copy link
Member

This is fixed on master.

@ilevkivskyi ilevkivskyi closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
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