"type[UnionType]" is not assignable to "type"
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
Pyright rejects assigning `UnionType` to a type variable, although `UnionType` is a valid type object.
**Minimal repro:**
```python
from types import UnionType
_: type = UnionType
```
```bash
> pyright test.py
error: Type "type[UnionType]" is not assignable to declared type "type" (reportAssignmentType)
```
**Environment**
* Reproduced with Pyright CLI version **1.1.403**
* Also reproduced on `main` (commit: `e32022ce6b12c74aca5cb00b267bda81995f3b86`)
* [Playground link](https://pyright-play.net/?pyrightVersion=1.1.403&code=GYJw9gtgBALgngBwKYGcoEsILCGUCqAdumIQCqJIBQoksi6hA5hljngIKFxVUD6ALnrIoAXgLFSFZEA)
Contributor guide
Research direction
Start by reproducing the issue in test.py with the Pyright CLI, using version 1.1.403 or the referenced main commit. Trace how assignment compatibility handles the `type[UnionType]` expression. Done means the example no longer produces reportAssignmentType while existing type-checking behavior remains intact.
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
- Clearly specified
- Newbie friendliness
- 55/100