[comparison-overlap] error on `Type[Any]` typed var compared with `Any`
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Since mypy version 1.11 the comparison-overlap error occurred in the following code. This error did not occur in older versions that I have used before.
To Reproduce
from typing import Type, Any
def test(tp: Type[Any]) -> None:
if tp == Any:
return
Expected Behavior
No error
Actual Behavior
error: Non-overlapping equality check (left operand type: "type[Any]", right operand type: "<typing special form>")
[comparison-overlap]
if tp == Any:
^~~~~~~~~~
Your Environment
- Mypy version used: 1.11.1
- Mypy command-line flags:
--strict-equality - Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.12.4
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
Run the provided Python 3.12.4 reproducer with mypy 1.11.1 and --strict-equality, then trace how comparison-overlap handles Type[Any] compared with Any. Add regression coverage for this case and verify that the diagnostic is no longer emitted while other strict-equality checks remain 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
- Mostly clear
- Newbie friendliness
- 45/100