Found out order of the types are important in the same python file for type hints. This will throw Undefined name: B error if the class is used before it’s defined. For example, consider the following code:

from typing import List

class A:
    items: List[B]

class B:
    name: str

To fix, we should reorder the classes:

from typing import List

class B:
    name: str

class A:
    items: List[B]