microsoft / microsoft/pyright

Tuples are inferred as containing literal value types despite explicit annotation with general type

Open
#11,381 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

```py
t1: Tuple[int, ...] = (1, 2, 3)
t2: Tuple[int, ...] = (1, 2, 4)

t1 >= t2
```

`Operator ">=" not supported for types "tuple[Literal[1], Literal[2], Literal[3]]" and "tuple[Literal[1], Literal[2], Literal[4]]"`

`Pylance language server 2026.2.1 (pyright version 1.1.408, commit 138238b4)`

This is a regression of #1170. Specifically the case mentioned in https://github.com/microsoft/pyright/issues/1170#issuecomment-727048387. @erictraut [said](https://github.com/microsoft/pyright/issues/1170#issuecomment-727212010) that he added a test case for this to the test suite, you should check that it is still there.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported comparison with the two annotated tuples, then inspect the existing test case referenced from issue #1170 in the test suite. Trace the tuple type inference involved in that case; done means explicit Tuple[int, ...] annotations no longer produce literal-element comparison errors and the regression test passes.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.