我正在使用Python2.7和PyCharm Community 2016.3.2。我有以下代码片段:
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]。我不明白为什么我在docstring中的类型提示在这种情况下不起作用。
发布于 2017-03-24 16:35:42
替换
dict[str: child_node.ChildNode]
使用
dict[str, child_node.ChildNode]
https://stackoverflow.com/questions/42954718
复制相似问题