microsoft / microsoft/pyright

Overload evaluation does not conform to typing spec

Open
#10,232 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug spec compliance
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

A recent addition to the typing spec conformance test uncovered a case that pyright is handling incorrectly.

This is found in the `overloads_evaluation.py` test in [this PR](https://github.com/python/typing/pull/1957).

```python
@overload
def example5(obj: list[int]) -> list[int]: ...

@overload
def example5(obj: list[str]) -> list[str]: ...

def example5(obj: Any) -> list[Any]:
return []

def check_example5(b: list[Any]) -> None:
assert_type(example5(b), Any)
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the overloads_evaluation.py conformance test referenced in the issue and inspect how pyright evaluates example5 with list[Any]. Compare the result with the typing specification and the linked typing conformance PR. The work is done when the test's assert_type(example5(b), Any) expectation passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.