9 个月后更新:版本 0.991 没有错误mypy。mypy该问题可能是同时已修复的问题。
您能解释一下为什么mypy抱怨这个演示程序的最后一行吗?我不明白出了什么问题。程序运行良好并打印出预期的输出。
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
Run Code Online (Sandbox Code Playgroud)