Forward Declarations for IDE

In PyCharm function annotations help the IDE determine return types.  However, it seems to ignore forward declarations.  Given the following class, it will not be able to determine that the parent method returns type "Node".

class Node:
    def __init(self, parent: 'Node'=None):
        self._parent = parent

    def parent(self) -> 'Node':
        return self._parent

Is there some other way to do forward declarations for PyCharm, or is it just broken?

John
2 comments
Comment actions Permalink
Have you tried using type hinting in docstrings?

See example in screenshot.

Screenshot 2014-10-24 09.18.30.png
0
Comment actions Permalink
The :rtype: type hinting did the trick.  Thanks.
0

Please sign in to leave a comment.