Skip to content
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

error: "Callable[..., Any]" not callable (how is this even possible?) #14751

Closed
randolf-scholz opened this issue Feb 21, 2023 · 1 comment
Closed
Labels
bug mypy got something wrong

Comments

@randolf-scholz
Copy link
Contributor

Bug Report

MyPy says a callable is not callable...

To Reproduce

https://mypy-play.net/?mypy=master&python=3.11&gist=f3a073087c600a0875ef54149ef27e24

from types import FunctionType
from typing import Callable


def show_annotations(func: Callable) -> None:
    if isinstance(func, FunctionType):
        print(func.__annotations__)
    else:
        print(func.__call__.__annotations__)  # ✘ error [operator]


class Foo:
    def __call__(self) -> None:
        pass


def foo() -> None:
    pass


show_annotations(foo)
show_annotations(Foo())

Expected Behavior

The code looks good to me, typing-wise.

Actual Behavior

main.py:9: error: "Callable[..., Any]" not callable [operator]
Found 1 error in 1 file (checked 1 source file)

@randolf-scholz randolf-scholz added the bug mypy got something wrong label Feb 21, 2023
@AlexWaygood
Copy link
Member

Duplicate of #5079

@AlexWaygood AlexWaygood marked this as a duplicate of #5079 Feb 21, 2023
@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2023
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