-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
Please consider
import dataclasses as dtc
import typing as tp
T = tp.TypeVar('T', int, str, covariant=True)
@dtc.dataclass(frozen=True)
class C(tp.Generic[T]):
c: type[T]
c_decision: dict[bool, C] = {
True: C(int),
False: C(str),
}
reveal_type(c_decision[True])
reveal_type(c_decision[False])
then
$ mypy -V
mypy 0.942
$ mypy issues-mypy/t9.py
issues-mypy/t9c.py:15: note: Revealed type is "t9c.C*[Any]"
issues-mypy/t9c.py:16: note: Revealed type is "t9c.C*[Any]"
If I remove type annotation for c_decision
c_decision = {
True: C(int),
False: C(str),
}
then the output is
issues-mypy/t9c.py:15: note: Revealed type is "builtins.object*"
issues-mypy/t9c.py:16: note: Revealed type is "builtins.object*"
EDIT: rewriting the description to try to simplify the problem
Reactions are currently unavailable