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

Generics as defaults #17067

Closed
genglandaer opened this issue Mar 26, 2024 · 1 comment
Closed

Generics as defaults #17067

genglandaer opened this issue Mar 26, 2024 · 1 comment
Labels
bug mypy got something wrong

Comments

@genglandaer
Copy link

genglandaer commented Mar 26, 2024

Bug Report

When you use a function as a default in a generic class, its types are not interpreted correctly

(A clear and concise description of what the bug is.)

To Reproduce

LINK TO GIST

Expected Behavior

When passing in a lambda to return the value passed in, it should interpret that the second generic type is the same as the first.

Actual Behavior

It is ok if you pass a lambda in the constructor. It throws an error if you have it as a default in the constructor.

main.py:8: error: Incompatible default for argument "parse_to" (default has type "Callable[[V], V]", argument has type "Callable[[V], K]") [assignment]
main.py:8: error: Incompatible return value type (got "V", expected "K") [return-value]

@genglandaer genglandaer added the bug mypy got something wrong label Mar 26, 2024
@hauntsaninja
Copy link
Collaborator

Duplicate of #3737

@hauntsaninja hauntsaninja marked this as a duplicate of #3737 Mar 27, 2024
@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2024
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