Skip to content

lambda expression not recognised as FunctionType, reported as Callable[[Any], Any] instead #10320

Closed
@neutrinoceros

Description

@neutrinoceros

Bug Report

Very likely related to #8869 and #9934

To Reproduce

(Write your steps here:)

run mypy against this file

from types import FunctionType

my_lambdas:dict[str, FunctionType] = {}
my_lambdas["example"] = lambda x: x**2

Expected Behavior
no errors or warnings (since is instance(lambda x: x**2, FunctionType) evaluates to True).

Actual Behavior

mypy_bug.py:4: error: Incompatible types in assignment (expression has type "Callable[[Any], Any]", target has type "FunctionType")
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.812
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: Python 3.9.1
  • Operating system and version: OSX

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