In addition to InSync's solution, you can also do this:
from typing import Self class A: B: 'A' A.B = A()
This is an example of a forward reference, and mypy handles those by putting the type name in quotes.