【发布时间】:2017-08-14 17:57:50
【问题描述】:
我正在使用 Python 2.7 和 PyCharm 社区版 2016.3.2。我有以下 sn-p 代码:
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]。我不明白为什么我在文档字符串中的类型提示在这种情况下不起作用。
【问题讨论】:
标签: python python-2.7 pycharm code-completion type-hinting