I want this logical type structure:
from typing import List, Dict, Union
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?
I believe I can inline the individual types, typing out the full definition each time, to allow recursion. I'd prefer to avoid this, as it's bulky, and less clear.