Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
neutrinoceros opened this issue Apr 13, 2021 · 2 comments
Labels
bug mypy got something wrong

Comments

@neutrinoceros
Copy link

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
@neutrinoceros neutrinoceros added the bug mypy got something wrong label Apr 13, 2021
@JelleZijlstra
Copy link
Member

FunctionType should not be used in type annotations at the moment. See #5958 and #3171 for some context.

@neutrinoceros
Copy link
Author

fair enough. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants