How to use an inner class as a type annotation in another inner class?

Viewed 398

I have the next structure of classes:

class Root:
    @dataclass
    class Leaf:
        pass

    @dataclass
    class Node:
        leaf: Leaf

The problem is PyCharm doesn't see Leaf class, I also tried to specify it as leaf: Root.Leaf and even 'Root'.Leaf... There was same result.
How to declare a field type in the inner class if the type is another inner class? Is it possible in python?
P.S. I can make the Leaf class an inner of the Node class but I am interested in my example.

0 Answers
Related