microsoft / microsoft/pyright

A specific enum can lead to errors in inferring tuples

Open
#11,339 4 comments 0 reactions 1 assignee View on GitHub

@bschnurr is already working on this.

Since Mar 20, 2026.

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

Description

## Environment data

- Pylance version: 2026.1.1
- OS and version: Windows 10 22H2
- Python version (& distribution if applicable, e.g. Anaconda): 3.14.3 (tags/v3.14.3:323c59a, Feb 3 2026, 16:04:56) [MSC v.1944 64 bit (AMD64)]

## Code Snippet

```python
import enum

class A(enum.Enum):
a = (True, False)
b = (False, True)
c = (True, True)
d = (False, False)

def f(q: A, w: A) -> bool:
return q.value < w.value

a = A.a.value
b = A.b.value

print(a < b)
```

## Repro Steps

1. Copy the code Snippet

## Expected behavior

No error reported

## Actual behavior

```json
[{
"resource": "/C:/Users/Administrator/Documents/Python/test/1.py",
"owner": "Pylance8",
"code": {
"value": "reportOperatorIssue",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportOperatorIssue.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 8,
"message": "类型“tuple[Literal[True], Literal[False]] | tuple[Literal[False], Literal[True]] | tuple[Literal[True], Literal[True]] | tuple[Literal[False], Literal[False]]”和“tuple[Literal[True], Literal[False]] | tuple[Literal[False], Literal[True]] | tuple[Literal[True], Literal[True]] | tuple[Literal[False], Literal[False]]”不支持运算符“<”\n  预期类型为“bool”时,类型“tuple[Literal[True], Literal[True]]”和“tuple[Literal[False], Literal[False]]”不支持运算符“<”\n  预期类型为“bool”时,类型“tuple[Literal[False], Literal[False]]”和“tuple[Literal[True], Literal[True]]”不支持运算符“<”",
"source": "Pylance",
"startLineNumber": 46,
"startColumn": 12,
"endLineNumber": 46,
"endColumn": 29,
"modelVersionId": 529,
"origin": "extHost1"
}]
```

## Logs

```
2026-03-21 05:32:15.449 [info] (17820): Server root directory: file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist
2026-03-21 05:32:15.449 [info] (17820): Pylance language server 2026.1.1 (pyright version 1.1.408, commit 138238b4) starting
2026-03-21 05:32:15.452 [info] (17820): Starting service instance "test" for workspace "c:\Users\Administrator\Documents\Python\test"
2026-03-21 05:32:15.542 [info] (17820): FG(test): Setting environmentName for service "test": "Python 3.14.3"
2026-03-21 05:32:15.543 [info] (17820): FG(test): Setting pythonPath for service "test": "C:\Users\Administrator\AppData\Local\Programs\Python\Python314\python.exe"
2026-03-21 05:32:15.543 [info] (17820): FG(test): No include entries specified; assuming c:\Users\Administrator\Documents\Python\test
2026-03-21 05:32:15.543 [info] (17820): FG(test): Auto-excluding **/node_modules
2026-03-21 05:32:15.543 [info] (17820): FG(test): Auto-excluding **/__pycache__
2026-03-21 05:32:15.544 [info] (17820): FG(test): Auto-excluding **/.*
2026-03-21 05:32:15.610 [info] (17820): FG(test): Assuming Python version 3.14.3.final.0
2026-03-21 05:32:15.745 [info] (17820): [Editable Installs] Starting dynamic pth file resolution for Python: C:\Users\Administrator\AppData\Local\Programs\Python\Python314\python.exe
2026-03-21 05:32:15.755 [info] (17820): [Editable Installs] No sandbox available for Python C:\Users\Administrator\AppData\Local\Programs\Python\Python314\python.exe. Dynamic pth file resolution requires Python 3.13 or later.
2026-03-21 05:32:15.771 [info] (17820): FG(test): Found 6 source files
2026-03-21 05:32:15.786 [info] (17820): Settings have not changed. Skipping update.
2026-03-21 05:32:15.793 [info] (17820): Settings have not changed. Skipping update.
2026-03-21 05:32:15.796 [info] (17820): Settings have not changed. Skipping update.
2026-03-21 05:32:16.126 [info] (17820): PQ(test): Priority queue background worker(2) root directory: file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist
2026-03-21 05:32:16.127 [info] (17820): PQ(test): Priority queue background worker(2) started
2026-03-21 05:32:16.272 [info] (17820): FG(test): IDX(test): Indexer background runner(3) root directory: file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist (index)
2026-03-21 05:32:16.272 [info] (17820): FG(test): IDX(test): Indexing(3) started
2026-03-21 05:32:17.165 [info] (17820): FG(test): IDX(test): scanned(3) 353 files over 1 exec env
2026-03-21 05:32:17.436 [info] (17820): FG(test): IDX(test): indexed(3) 353 files over 1 exec env
2026-03-21 05:32:17.510 [info] (17820): FG(test): IDX(test): Indexing finished(3).
2026-03-21 05:32:23.882 [info] (17820): Starting service instance "" for workspace ""
2026-03-21 05:32:23.901 [info] (17820): FG(): Setting environmentName for service "": "Python 3.14.3"
2026-03-21 05:32:23.901 [info] (17820): FG(): Setting pythonPath for service "": "c:\Users\Administrator\AppData\Local\Programs\Python\Python314\python.exe"
2026-03-21 05:32:23.902 [info] (17820): FG(): No include entries specified; assuming \
2026-03-21 05:32:23.902 [info] (17820): FG(): Auto-excluding **/node_modules
2026-03-21 05:32:23.902 [info] (17820): FG(): Auto-excluding **/__pycache__
2026-03-21 05:32:23.902 [info] (17820): FG(): Auto-excluding **/.*
2026-03-21 05:32:23.966 [info] (17820): FG(): Assuming Python version 3.14.3.final.0
2026-03-21 05:32:24.097 [error] (17820): FG(): File or directory "\" does not exist.
2026-03-21 05:32:24.097 [info] (17820): FG(): No source files found.
2026-03-21 05:32:24.405 [info] (17820): PQ(): Priority queue background worker(5) root directory: file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist
2026-03-21 05:32:24.406 [info] (17820): PQ(): Priority queue background worker(5) started
2026-03-21 05:32:25.205 [info] Client: The existing extension didn't exit within 10 seconds. New instance will start, but you might encounter issues.
2026-03-21 05:32:25.205 [info] Client: Pylance client (2026.1.1) started with python extension (2026.4.0)
2026-03-21 05:32:25.836 [info] (17820): Loading background bundle file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist/copilot-background.bundle.js into file:///c%3A/Users/Administrator/Documents/Python/test...
2026-03-21 05:32:25.837 [info] (17820): Loading background bundle file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist/copilot-background.bundle.js into ...
2026-03-21 05:32:25.951 [info] (17820): Starting Mcp server id:3277 ...
2026-03-21 05:52:39.544 [info] Client: Pylance client (2026.1.1) started with python extension (2026.4.0)
2026-03-21 05:52:39.920 [info] (17012): Server root directory: file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist
2026-03-21 05:52:40.012 [info] (17012): Pylance language server 2026.1.1 (pyright version 1.1.408, commit 138238b4) starting
2026-03-21 05:52:40.046 [info] (17012): Starting service instance "test" for workspace "c:\Users\Administrator\Documents\Python\test"
2026-03-21 05:52:40.802 [info] (17012): Loading background bundle file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist/copilot-background.bundle.js into file:///c%3A/Users/Administrator/Documents/Python/test...
2026-03-21 05:52:40.919 [info] (17012): FG(test): Setting environmentName for service "test": "Python 3.14.3"
2026-03-21 05:52:40.919 [info] (17012): FG(test): Setting pythonPath for service "test": "C:\Users\Administrator\AppData\Local\Programs\Python\Python314\python.exe"
2026-03-21 05:52:40.919 [info] (17012): FG(test): No include entries specified; assuming c:\Users\Administrator\Documents\Python\test
2026-03-21 05:52:40.920 [info] (17012): FG(test): Auto-excluding **/node_modules
2026-03-21 05:52:40.920 [info] (17012): FG(test): Auto-excluding **/__pycache__
2026-03-21 05:52:40.920 [info] (17012): FG(test): Auto-excluding **/.*
2026-03-21 05:52:40.994 [info] (17012): FG(test): Assuming Python version 3.14.3.final.0
2026-03-21 05:52:41.127 [info] (17012): [Editable Installs] Starting dynamic pth file resolution for Python: C:\Users\Administrator\AppData\Local\Programs\Python\Python314\python.exe
2026-03-21 05:52:41.138 [info] (17012): [Editable Installs] No sandbox available for Python C:\Users\Administrator\AppData\Local\Programs\Python\Python314\python.exe. Dynamic pth file resolution requires Python 3.13 or later.
2026-03-21 05:52:41.154 [info] (17012): FG(test): Found 6 source files
2026-03-21 05:52:41.169 [info] (17012): Settings have not changed. Skipping update.
2026-03-21 05:52:41.172 [info] (17012): Starting Mcp server id:4736 ...
2026-03-21 05:52:41.194 [info] (17012): Settings have not changed. Skipping update.
2026-03-21 05:52:41.205 [info] (17012): Settings have not changed. Skipping update.
2026-03-21 05:52:41.390 [info] (17012): PQ(test): Priority queue background worker(2) root directory: file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist
2026-03-21 05:52:41.390 [info] (17012): PQ(test): Priority queue background worker(2) started
2026-03-21 05:52:41.674 [info] (17012): FG(test): IDX(test): Indexer background runner(3) root directory: file:///c%3A/Users/Administrator/.vscode/extensions/ms-python.vscode-pylance-2026.1.1/dist (index)
2026-03-21 05:52:41.674 [info] (17012): FG(test): IDX(test): Indexing(3) started
2026-03-21 05:52:42.624 [info] (17012): FG(test): IDX(test): scanned(3) 353 files over 1 exec env
2026-03-21 05:52:42.915 [info] (17012): FG(test): IDX(test): indexed(3) 353 files over 1 exec env
2026-03-21 05:52:42.987 [info] (17012): FG(test): IDX(test): Indexing finished(3).
```

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.