Use the name of the recursive type in its declaration. For example:
class Heh:
child_hehs: list['Heh']
If you can use python 3.7.0b1 and above you can use Postponed Evaluation of Annotations.
from __future__ import annotations
class Heh:
child_hehs: list[Heh]
This feature is expected to become part of the language in python 3.10 (in other words, without __future__ import).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…