What is the reason for the "<nothing> not callable" mypy error?

Viewed 386

Could you please explain why mypy complains about the last line of this demo program? I don't understand what is wrong. The program runs fine and prints the expected output.

from collections.abc import Iterable, Callable

class RevTuple(tuple):
    def __new__(cls, arg):
        return super().__new__(cls, reversed(arg))

data = [1,3,5]

func: Callable[[Iterable], tuple]

func = tuple
print(func(data))

func = RevTuple
print(func(data))   # mypy: error: <nothing> not callable
0 Answers
Related