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

new type inference regression on callable #16458

Closed
bzoracler opened this issue Nov 11, 2023 · 1 comment
Closed

new type inference regression on callable #16458

bzoracler opened this issue Nov 11, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@bzoracler
Copy link
Contributor

bzoracler commented Nov 11, 2023

Bug Report

The new type inference introduced (default in mypy 1.7) causes the following failure:

To Reproduce & Actual Behaviour

mypy-play.net

import typing_extensions as t

T = t.TypeVar("T")
deco: t.Callable[[t.Callable[..., T]], t.Callable[..., T]]

@deco  # mypy: Argument 1 has incompatible type "Callable[[T], T | int]"; expected "Callable[..., Never]" [arg-type]
def func(item: T, /) -> T | int:
    return 0

The discovery of this was with @deco as @functools.singledispatch, which has signature def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ....

Expected Behavior

No issues (as with mypy 1.6.1 without --new-type-inference and 1.7 with --old-type-inference)

Your Environment

  • Mypy version used: 1.6.1 with --new-type-inference, 1.7, master,
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.10, 3.11
@bzoracler bzoracler added the bug mypy got something wrong label Nov 11, 2023
@ilevkivskyi
Copy link
Member

This is a duplicate of #16451 (this has a much simpler repro, but that issue is older, so closing this one).

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