Finding edge cases for PEPs 484, 563, and 649 (type annotations)

Edge case: forward references

Referencing a class within its own type annotations.

class BinaryTree:
    value: Any | None
    lhs: BinaryTree | None
    rhs: BinaryTree | None

Fails for …

  • Executed at runtime (PEP 484)
1 Like