Skip to content

error: Expression is of type "Any", not "Any" (Using Any as a type) #20859

@George-Ogden

Description

@George-Ogden

Here is a minimum reproducible example of this bug:

from typing import Any, assert_type

def foo[T](typ: type[T]) -> T: ...

assert_type(foo(Any), Any)

reveal_type(foo(Any), Any)
reveal_type(Any)

which produces this output:

error: Expression is of type "Any", not "Any"  [assert-type]
note: Revealed type is "typing.Any"
note: Revealed type is "def () -> typing.Any"

I did not expect this to cause any mypy errors.
Or, it would say that Any is not a type.

Your Environment

  • Mypy version used: mypy 1.19.1 (compiled: yes)
  • Mypy command-line flags: NA
  • Mypy configuration options from mypy.ini (and other config files): NA
  • Python version used: 3.13.9 (also reproduced in 3.14.3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions