Matching generic return type of `SupportsGetItem`
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
# Describe the bug
`pyrefly` does not match the generic return type of `SupportsGetItem` properly.
# Code or Screenshots
```python
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()
else:
return x[0]
```
# Error messages
```text
ERROR sandbox.py:18:16-24: Returned type `Series` is not assignable to declared return type `T` [[bad-return](https://pyrefly.org/en/docs/error-kinds/#bad-return)]
```
- `mypy` works fine: https://mypy-play.net/?gist=3aaea716bd3429a90a96457884f46712
### Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEA%2Bg2AK4AuLlMTdENxuSmzoZ0uNqjYRc6OAB10CsNXptSxCOgDmvfoOEAVAJoAFAKIMAwgAkzlgNIBJAHIBxADR0AgulKeD6jAAaqiUCgoQYHTG5la2Di6uiAp0qXTKtIxqxPAAFjCYugJCdADKLMTFbHCuMGyObDA04egAxlCocHBlMJQQ8Ih0hMMt7Z3dACKSqABilKg0MMnoaXSYMFFMWnUQjTRMABRwMFBgngDWMKSDuNgAVjCtbACUdAC0AHw9fQMpq2lcDiUFalXr9OAHZ4tAx0AC80UCIUoBzkIAMqKhiiwG3SB3wg3KlX0NTqDSaAG0fH5ogBdV6faLLVaRXhwTRwCRtGB4zxTCRzBYwZ5M-6pQGcEFg%2BCQv6pE7HEWi8XAuj4ckABhpChA7hAZC4YCgpEIbFoUAoAGI6CZSAajXQ0Fg8Pg6K0ZJAtJxJNJ0IQFFbQTA6Lk2GxiHBEAB6SP6jZGwiCLSRmDoSOYXCtOCRt3oD1eqQySPpQQiABuqGgqGwsFd7ognvmBZWuGITbgfvQZDYuRkb1LvTZMjhdFRAGZCABGABMqIU5N61EocC16BY6D4VQKb0wEC4Twg-eHAHJ62IuEeFGI2G8uABHFi7reXUhvVCtVrwbrwo8Ad1C6AvdAQAAX11N8pH7GZoBgChHRwAgSHIYCgA
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.