Incorrect diagnostic message for `isinstance(None, object)`
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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