facebook / facebook/pyrefly

use union of overload signatures return types as inferred return type for unannotated impl

Open
#1,174 2 comments 0 reactions 0 assignees View on GitHub
needs-discussion overloads typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```py
from typing import overload

@overload
def foo(i: str) -> list[object]: ... # Overload return type `list[object]` is not assignable to implementation return type `list[int]`
@overload
def foo(i: int) -> list[object]: ... # Overload return type `list[object]` is not assignable to implementation return type `list[int]`

def foo(i):
# bonus: reveal_type(i) should be `str | int`
return [1]
```

here we could infer `list[object]` and not see any error

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.