typish.functions._get_args   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_args() 0 11 1
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