typish.functions._get_args.get_args()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 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