Skip to content

[1.16 regression] assigning a lambda to subclass w/ generics #19165

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

Closed
Redoubts opened this issue May 29, 2025 · 4 comments
Closed

[1.16 regression] assigning a lambda to subclass w/ generics #19165

Redoubts opened this issue May 29, 2025 · 4 comments
Labels
bug mypy got something wrong

Comments

@Redoubts
Copy link

Redoubts commented May 29, 2025

Bug Report

Consider the following:

https://mypy-play.net/?mypy=latest&python=3.12&gist=29ddead67873ff6c1f1bf36de8726bd7

This works without error in 1.15 mypy. But in the new 1.16 version, one would see Incompatible return value type (got "int", expected "T") on converter2

Your Environment

  • Mypy version used: 1.16
  • Mypy command-line flags: (defaults)
  • Mypy configuration options from mypy.ini (and other config files): n/a
  • Python version used: 3.11 & 3.12
@Redoubts Redoubts added the bug mypy got something wrong label May 29, 2025
@hauntsaninja hauntsaninja changed the title 'Incompatible return value type (... expected "T")' when assigning a lambda to a class w/ generics [1.16 regression] assigning a lambda to subclass w/ generics May 29, 2025
@hauntsaninja
Copy link
Collaborator

This will be #18847

@ilevkivskyi
Copy link
Member

I will take a look at this (hopefully during weekend). Most likely I just missed some edge case (since it works for non-lambda overrides).

@ilevkivskyi
Copy link
Member

Oh well, this is fixed on master now by #18943. I am not sure however if it is worth including in a point release, as this is a big PR and regression doesn't seem urgent. Anyway, I will leave this decision up to @JukkaL

@Redoubts
Copy link
Author

Since there’s an obvious workaround, I’m not too pressed about letting this float to the next real release

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

3 participants