Python的3.8提供了typing.get_origin()
与typing.get_args()
此!
assert get_origin(Dict[str, int]) is dict
assert get_args(Dict[int, str]) == (int, str)
assert get_origin(Union[int, str]) is Union
assert get_args(Union[int, str]) == (int, str)
参见https://docs.python.org/3/library/typing.html#typing.get_origin