Sam Hooke

Python forward reference

Prior to Python 3.12, recursive type require from __future__ import annotations:

Example of a recursive type
from __future__ import annotations

class Something:
    def __init__(self, parent: Something | None) -> None:
        self.parent: Something | None = parent