mypy icon indicating copy to clipboard operation
mypy copied to clipboard

[comparison-overlap] error on `Type[Any]` typed var compared with `Any`

Open alesmrazek opened this issue 1 year ago • 0 comments

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

alesmrazek avatar Aug 13 '24 07:08 alesmrazek