I need to do some introspection on dataclasses. currently, the project is running on python 3.8, but soon, it will be upgraded. However, right now, I would like to know how I can check if a type is a GenericAlias, and get its t_orig, and t_args. How can I do is so that :
On python 3.8 :
- It works with typing.List[int]
On python 3.9+ :
- It works with typing.List[int]
- It works with list[int]
The same code works all 3.8+ versions
get_args
/get_origin
not work for you? What exactly do you want to check? Just if something islist[int]
/List[int]
or something more general about generic alias types?