如何解决为什么 mypy 在使用 TypedDict 别名时抱怨“对象”不可调用
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'
为什么 Q
和 T
不一样?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。