Total Complexity | 1 |
Total Lines | 15 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import typing |
||
2 | |||
3 | |||
4 | def get_args(t: type) -> typing.Tuple[type, ...]: |
||
5 | """ |
||
6 | Get the arguments from a collection type (e.g. ``typing.List[int]``) as a |
||
7 | ``tuple``. |
||
8 | :param t: the collection type. |
||
9 | :return: a ``tuple`` containing types. |
||
10 | """ |
||
11 | args_ = getattr(t, '__args__', tuple()) or tuple() |
||
12 | args = tuple([attr for attr in args_ |
||
13 | if type(attr) != typing.TypeVar]) |
||
14 | return args |
||
15 |