2017-03-22 7 views
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_nodeschild_nodesにカーソルを合わせると、推測された型はAny代わりのDict[str, ChildNode]として示されていることです。この場合、docstring内の型ヒントがうまくいかない理由は分かりません。

答えて

1

dict[str, child_node.ChildNode]

dict[str: child_node.ChildNode]

を交換してください

関連する問題