I'm not really sure if this is more of a bug or a feature request, but basically I was playing around with TypedDicts and I thought this would be really interesting.
To Reproduce
fromtypingimportTypedDict, Protocol, CallableclassX(TypedDict):
a: intb: strclassGetX[K, V](Protocol):
def__getitem__(self, key: K, /) ->V: ...
x: X= ...
deff[T, R](k: T, d: GetX[T, R]) ->R:
returnd[k]
reveal_type(x["b"]) # N: Revealed type is "str"reveal_type(f("b", x)) # N: Revealed type is "object"
Expected Behavior
Both get revealed as str.
Actual Behavior
One gets revealed as object.
Your Environment
Reproduced in mypy-play.
Mypy version used: 2.4.0
Mypy command-line flags: N/A
Mypy configuration options from mypy.ini (and other config files): N/A
Activity