0
我正在使用Python 2.7和PyCharm Community Edition 2016.3.2。我有下面的代碼片段:__init__中的Pycharm類型提示不起作用
class ParentNode(node.Node):
"""ParentNode is a subclass of Node but also takes an additional child_nodes parameter.
@type child_nodes: dict[str: child_node.ChildNode]
"""
def __init__(self, name, node_type, FSPs, CTT_distributions, TMR_distributions,
prob_on_convoy, rep_rndstrm, child_nodes):
"""ParentNode is a subclass of Node but also takes an additional child_nodes parameter.
@type child_nodes: dict[str: child_node.ChildNode]
"""
node.Node.__init__(self, name, node_type, FSPs, CTT_distributions, TMR_distributions,
prob_on_convoy, rep_rndstrm)
self.network_status = 'parent'
self.child_nodes = child_nodes
的問題是,當我將鼠標懸停在self.child_nodes
或child_nodes
,推斷的類型顯示爲Any
,而不是Dict[str, ChildNode]
。我不明白爲什麼我在文檔字符串中使用的typehinting在這種情況下不起作用。