microsoft / microsoft/pyright

`Any | Never` evaluates to `Never` instead of `Any`

Open
#10,625 0 comments 3 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

**Describe the bug**
A type annotation like `Any | Never` (the `Any` part could be replaced with any subclass of `Any`) evaluates to `Never` instead of `Any`.

**Code or Screenshots**
```python
from typing import Any, Never

def f(x: Any | Never):
reveal_type(x) # `Never`
```

**VS Code extension or command-line**
Confirmed on Pyright 1.1.402, but this behavior can also be seen on much older versions.

Contributor guide

Open the contributing guide

Research direction

Start with the Python reproducer in the issue and run it against Pyright 1.1.402, checking the revealed type for `Any | Never`. No source file or test is named; done means the expression reveals `Any` rather than `Never`, with regression coverage added in the relevant type-evaluation tests.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.