为什么 mypy 在使用 TypedDict 别名时抱怨“对象”不可调用

问题描述

我有一个名为 debug.py文件

from typing import TypedDict

class T(TypedDict):
    a: int


Q = T

x = Q(a=1)

当我跑步时

mypy debug.py

我明白了

debug.py:9: error: "object" not callable
Found 1 error in 1 file (checked 1 source file)

如果我用 x = Q(a=1) 替换 x = T(a=1),那么抱怨就会消失。

使用 reveal_type 个节目

debug.py:9: note: Revealed type is 'builtins.object'
debug.py:10: note: Revealed type is 'def () -> debug.T'

为什么 QT 不一样?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)