microsoft / microsoft/pyright

Incorrect diagnostic message for `isinstance(None, object)`

Open
#11,155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug
Incorrect diagnostic message for isinstance(None, object); this expression evaluates to True, but raises the following diagnostic:

Unnecessary isinstance call; "None" is never an instance of "object"  (reportUnnecessaryIsInstance)

This message should replace the word never with always (as it does with isinstance("hi", object), for example)

Code or Screenshots
Code sample in pyright playground

print(isinstance(None, object))  # True

VS Code extension or command-line

Are you running pyright as a VS Code extension, a language server in another editor, integrated into Pylance, or the command-line tool? Which version?

All of the above. I've checked with pyright versions 1.1.407 and 1.1.358

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.

Research direction

Reproduce the diagnostic for isinstance(None, object) in the linked Pyright playground or with the command-line tool, then trace the reportUnnecessaryIsInstance diagnostic. Compare it with the wording for isinstance("hi", object). Done means the None case reports that it is always an instance of object, with existing behavior preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.