Aug. 11, 2021
12:09 a.m.
For what it's worth, pyright supports recursive type aliases specifically to handle cases like this. There is an open issue in the mypy issue tracker that was created over six years ago: https://github.com/python/mypy/issues/731. It has over 250 upvotes, so I think it's safe to say that if someone were to implement this in mypy, they'd be a hero to many! If someone wants to try to implement it in mypy, I'd be happy to provide tips and pointers from my experience in implementing this in pyright. It was a relatively complicated feature, and it took several tries to get it right. -Eric -- Eric Traut Contributor to pylance & pyright Microsoft Corp.