from dataclasses import dataclass
from typing import Callable
@dataclass
class Repro:
fn: Callable[[int], str]
r = Repro(fn=repr)
assert "1" == r.fn(1)
but let's change the dataclass to a frozen one
from dataclasses import dataclass
from typing import Callable
@dataclass(frozen=True)
class Repro:
fn: Callable[[int], str]
r = Repro(fn=repr)
assert "1" == r.fn(1)
then
$ mypy t.py
t.py:9: error: Invalid self argument "Repro" to attribute function "fn" with type "Callable[[int], str]"
t.py:9: error: "str" not callable
Found 2 errors in 1 file (checked 1 source file)
@hauntsaninja I am reopening this issue as it seems the fix fell through the crack. I checked all 0.9xx versions and the fix never went to any of the releases, it seems
Activity
hauntsaninja commented on Jun 25, 2021
Can you repro against master? I don't think #10548 made it into any of the recent releases
wrobell commented on Jun 26, 2021
Works with mypy from master. Thanks.
dimaqq commented on Aug 24, 2021
Ah, would be nice to have this released! 🙏🏿
gwerbin commented on Sep 20, 2021
Does #10548 also fix #9489 and #10353? They both look like dupes of #5485 but I'm not totally sure if they're all subtly different in some way.
hauntsaninja commented on Sep 20, 2021
Yup, those should be fixed
wrobell commented on Apr 22, 2022
@hauntsaninja I am reopening this issue as it seems the fix fell through the crack. I checked all 0.9xx versions and the fix never went to any of the releases, it seems
https://mypy-play.net/?mypy=0.942&python=3.10&gist=ce6181fa059e3ea269f3356fd7af65be
hauntsaninja commented on Apr 22, 2022
Unfortunately, #10548 was reverted in #11571
erictraut commented on Aug 12, 2023
It looks like this fix eventually made it in. I'm not able to repro the problem with mypy 1.5, so I think this is safe to close.
hauntsaninja commented on Aug 12, 2023
Fixed in #13400