microsoft / microsoft/pyright

`isinstance` detects module as a type

Open
#10,605 1 comment 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

**Describe the bug**
No warning is displayed about the misuse of `isinstance` when an argument is not a type,

**Code or Screenshots**
```python
import datetime
import typing

a = typing.cast(datetime.datetime | None, None)

isinstance(a, datetime) # error: datetime is not a type
```

```
>>> py -m pyright test.py
0 errors, 0 warnings, 0 informations
```

**VS Code extension or command-line**
I'm using Pylance in strict mode and this issue arose. When I tested it on the command line, it persisted.

Pylance: 2025.6.1
Pyright (pip): 1.1.402

Contributor guide

Open the contributing guide

Research direction

Start by running the minimal Python example from the issue with Pyright 1.1.402 and inspect how the analyzer handles the second argument to isinstance. Trace the relevant type-checking path and add coverage for a module used where a type is expected; done means Pyright reports the misuse without introducing unrelated diagnostics.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.