Bug Report
mypy does not match the generic return type of SupportsGetItem properly.
This was proposed in astral-sh/ty#3988 (comment).
To Reproduce
https://mypy-play.net/?gist=b8bb3085f195314a6c7c89ed2bdd2576
from __future__ import annotations
from typing import TYPE_CHECKING, Any, TypeVar
if TYPE_CHECKING:
from _typeshed import SupportsGetItem
class Series: ...
class DataFrame:
def __getitem__(self, key: object) -> Series:
return Series()
T = TypeVar("T")
def f(x: SupportsGetItem[Any, T]) -> T:
if isinstance(x, DataFrame):
# return Series()
return 1 # false error-free
else:
return x[0]
Expected Behaviour
Report an error about return type
Actual Behaviour
No error
Your Environment
mypy playground
Bug Report
mypydoes not match the generic return type ofSupportsGetItemproperly.This was proposed in astral-sh/ty#3988 (comment).
To Reproduce
https://mypy-play.net/?gist=b8bb3085f195314a6c7c89ed2bdd2576
Expected Behaviour
Report an error about return type
Actual Behaviour
No error
Your Environment
mypyplayground