In Python 3.5, type annotations were added (see here).
Is there a way of defining recursive type annotations, such as for a tree-like structure?
class Employee(object):
def __init__(self, name: str, reports: List[Employee]):
self.name = name
self.reports = reports
In the above, it doesn't seem as though the annotation List[Employee]
works. Running the code results in this error:
NameError: name 'Employee' is not defined