Closed patrick-kidger closed 1 month ago
The following:
from typing import Generic, TypeVar, Annotated _T = TypeVar("_T") class Foo(Generic[_T]): def data(self) -> _T: ... Foo[Annotated[dict, ""]]().data()[""]
raises an error on the final line:
tmp3.py:9:1 - error: "__getitem__" method not defined on type "Annotated" (reportIndexIssue)
Replacing the _T with a direct Annotated[dict, ""] works.
_T
Annotated[dict, ""]
Expected behaviour is for the Annotated to be 'transparent', so that lookup works as if .data() gives a dictionary.
Annotated
.data()
pyright version 1.1.372 ran from the command line.
(PS - thanks for your message on jaxtyping! Looking forward to seeing where this goes :) )
Thanks for reporting. This will be fixed in the next release.
This is addressed in pyright 1.1.373.
The following:
raises an error on the final line:
Replacing the
_T
with a directAnnotated[dict, ""]
works.Expected behaviour is for the
Annotated
to be 'transparent', so that lookup works as if.data()
gives a dictionary.pyright version 1.1.372 ran from the command line.
(PS - thanks for your message on jaxtyping! Looking forward to seeing where this goes :) )