microsoft / microsoft/pyright

False positive when calling overloaded `*args` with union of tuples

Open
#10,813 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

Code sample in [pyright playground](https://pyright-play.net/?reportUnreachable=true&code=GYJw9gtgBALgngBwJYDsDmUkQWEMpgBuApiADZgCGAJgFC0ACRpFNt1xwUwYYAFACpKINAGcAXJhQwAlFAC0APigA5MCmKSAdDsbNyVOhy49%2BQkRKiiYIOUtXrNUHVvrHYxa3wAekmAFcEMmIAbVQYABopGABdKAAfWEDgkOsQKLSYu2U1DXFaKELuXkFvGVogA)

```python
from typing import overload

@overload
def foo(*args: int) -> None: ...
@overload
def foo(*args: str) -> None: ...

def test(x: tuple[int, int] | tuple[str, str]) -> None:
foo(*x)
```

Produces false positive error:

```
Argument of type "int | str" cannot be assigned to parameter "args" of type "str" in function "foo"
Type "int | str" is not assignable to type "str"
"int" is not assignable to "str" (reportArgumentType)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the example in the linked Pyright playground and confirm the false positive for foo(*x), where x is a union of tuples. Start by tracing overload resolution for expanded tuple arguments and identify how the union is being checked. Done means the example produces no reportArgumentType diagnostic while preserving checking for invalid calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.