Constrained type var is lost after chained method calls
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
This is a little bit of a follow up to https://github.com/facebook/pyrefly/issues/3621 since it is related to polars and generics.
The output of `group_by` is affected after bumping to the newly released `v1.1.0` (and `v1.1.1`). The outputs of `group_by` is incorrectly being inferred as `pl.DataFrame | pl.LazyFrame` rather than staying generic.
```python
from typing import TypeVar
import polars as pl
Frame = TypeVar("Frame", pl.DataFrame, pl.LazyFrame)
def aggregation(df1: Frame) -> Frame:
return df1.group_by("a").agg(pl.len())
```
```
ERROR Returned type `DataFrame | LazyFrame` is not assignable to declared return type `Frame` [bad-return]
```
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.