Skip to content

assert_type() not matching function type #15153

@DiegoBaldassarMilleuno

Description

@DiegoBaldassarMilleuno

Bug Report

'assert_type()' refuses to match a function to its own type.

To Reproduce

from typing import assert_type, Callable
def myfunc(arg: int) -> None: pass
assert_type(myfunc, Callable[[int], None])

# Gist URL: https://gist.github.com/mypy-play/50dde8e891d971d823c4c6af2e639834
# Playground URL: https://mypy-play.net/?mypy=latest&python=3.11&gist=50dde8e891d971d823c4c6af2e639834

Expected Behavior

No error.

Actual Behavior

main.py:5: error: Expression is of type "Callable[[int], None]", not "Callable[[int], None]"  [assert-type]
Found 1 error in 1 file (checked 1 source file)

The error disappears if the function takes no arguments.

Your Environment

  • Mypy version used: both 1.2.0 and current master branch (commit 29cc561)
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): default
  • Python version used: 3.11

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions