facebook / facebook/pyrefly

Class with varadic generic/typevartuple can be considered not assignable to itself

Open
#4,606 0 comments 0 reactions 0 assignees View on GitHub
typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```python
class A[*TS]:
def __init__(self, *state: *TS):
self.state: tuple[*TS] = state

def add[*TR](self: A[*TR, int, int]) -> A[*TR, int]:
# ERROR sandbox.py:6:16-68: Returned type `A[*TR, int]` is not assignable to declared return type `A[*TR, int]` [bad-return]
return A(*self.state[:-2], self.state[-2] + self.state[-1])

```

Python: 3.14

### Sandbox Link

https://pyrefly.org/sandbox/?project=v2.jZTNDoIwEIRfZRMOGPxpNIaY3jx41lRv2ES0RL2IkerzO10kBQUiBxK27bLd_Wa6LLOUyjKJdlvdrZQIAFkgil11clgfnyX7hNY4DernWLnP50yNwbrSnFPyP9UIs4XJ4aWZIR-sqnFPQCul1op85TKW03gcLyQppjczzvczOtQSHJxE0GPnqmi6c0GyOUrBndHxivuWc8kxNZiMW8Ykv3SyHET-3okczzQU5QP4pmEjMNXA9JeigDZloLoW_BP4nZ9waWA12d8CGHRGF2vvhRSiOp4_ziK7CZOfCtE4IcgJJn2lV_b-ZjrKmfoCadvxnf-Fb1jSG_bBGzp2w14a3w

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.