https://github.com/python/mypy/blob/a9f3b5e5b21304c63f93e96e0bfeab2fa2945a00/mypy/nodes.py#L2353-L2357 It looks like a cleaner solution.