How can I make a recursive Python type defined over several aliases?
问题 I want this logical type structure: ObjectType = Dict[str, 'EntryType'] ListType = List['EntryType'] EntryType = Union[str, 'ListType', 'ObjectType'] mypy reports these errors: mdl/structure.py:7: error: Cannot resolve name "ObjectType" (possible cyclic definition) mdl/structure.py:7: error: Cannot resolve name "EntryType" (possible cyclic definition) mdl/structure.py:8: error: Cannot resolve name "ListType" (possible cyclic definition) ... Is there some way to encode this recursive data type