-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Function in dataclass seen as function's return type not Callable #7404
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
Comments
Workaround - changed the dataclass to a typing.NamedTuple
|
This is actually completely unrelated to dataclasses, reduced: from typing import Callable
class A:
func: Callable[[int], None]
a: A
reveal_type(a.func) Which shows:
Off the top of my head this should work... I guess mypy is assuming that Also side note, your workaround only works because you didn't specify any EDIT: Welp this is indeed a complete duplicate of #5485, this is what I get for skimming the issue. IMO that issue should be renamed to signify it's not just dataclasses though. |
Updated the name of #5485. Closing as duplicate. |
This is a bug report.
Minimal (?) repro
Actual behavior
Expected behavior
Successful type check
Environment
Versions
Tested with:
Mypy config
[mypy]
warn_redundant_casts = True
warn_unused_ignores = True
incremental = True
Somewhat similar, possibly related
Dataclass with function fields incorrectly thinks first argument is self #5485
Not finding type specifications in make_dataclass #6063
Cannot assign to field of Callable type #708
The text was updated successfully, but these errors were encountered: