This code:
from dataclasses import dataclass
@dataclass
class MypyBug:
foo: str
troz = 5
MypyBug(foo='abc', troz=11)
…yields the error message:
test.py:8: error: Unexpected keyword argument "troz" for "MypyBug"
That's simply wrong. troz is an argument to the autogenerated __init__. The code executes perfectly at runtime.
If you remove all type hints from MypyBug, mypy stops complaining. If you add type hints for all members of MypyBug, it also stops complaining.
This code:
…yields the error message:
test.py:8: error: Unexpected keyword argument "troz" for "MypyBug"That's simply wrong.
trozis an argument to the autogenerated__init__. The code executes perfectly at runtime.If you remove all type hints from
MypyBug, mypy stops complaining. If you add type hints for all members ofMypyBug, it also stops complaining.