from typing import Dict
class MyDict(dict):
pass
def f() -> Dict[int, int]: # works
return {}
def g() -> MyDict[int, int]: # expected no type argument
return MyDict()
g()
$ python som.py
TypeError: 'type' object is not subscriptable
还有派林返回
E1136: Value 'MyDict' is unsubscriptable (unsubscriptable-object)
如何从Dict继承用于键入的结构?或者至少如何允许键入MyClass[Any]和MyClass[Any,Any]
目前没有回答
相关问题 更多 >
编程相关推荐