Closed
Description
Bug Report
mypy doesn't seem to propagate generics into dataclass
-generated methods correctly.
To Reproduce
from dataclasses import dataclass
from typing import TypeVar, Generic, Dict, Any
T = TypeVar("T")
class FloatValue:
pass
@dataclass
class ValueByKey(Generic[T]):
values: Dict[Any, T]
def foo(v: ValueByKey[FloatValue]):
reveal_type(v.values)
reveal_type(ValueByKey[FloatValue].__init__)
Expected Behavior
:; pipenv run mypy /tmp/footest.py
/tmp/footest.py:17: note: Revealed type is 'builtins.dict[Any, footest.FloatValue*]'
/tmp/footest.py:18: note: Revealed type is 'def (self: footest.ValueByKey[footest.FloatValue*], values: builtins.dict[Any, footest.FloatValue*])'
Actual Behavior
:; pipenv run mypy --version
mypy 0.790
:; pipenv run mypy /tmp/footest.py
/tmp/footest.py:17: note: Revealed type is 'builtins.dict[Any, footest.FloatValue*]'
/tmp/footest.py:18: note: Revealed type is 'def (self: footest.ValueByKey[T`1], values: builtins.dict[Any, T`1])'
Your Environment
- Mypy version used: 0.790
- Mypy command-line flags: see above
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.7.8
- Operating system and version: Arch Linux