def is_generic_type()

in azure_functions_worker/_thirdparty/typing_inspect.py [0:0]


def is_generic_type(tp):
    """Test if the given type is a generic type. This includes Generic itself,
     but excludes special typing constructs such as Union, Tuple, Callable,
     ClassVar.
    Examples::

        is_generic_type(int) == False
        is_generic_type(Union[int, str]) == False
        is_generic_type(Union[int, T]) == False
        is_generic_type(ClassVar[List[int]]) == False
        is_generic_type(Callable[..., T]) == False
        is_generic_type(Generic) == True
        is_generic_type(Generic[T]) == True
        is_generic_type(Iterable[int]) == True
        is_generic_type(Mapping) == True
        is_generic_type(MutableMapping[T, List[int]]) == True
        is_generic_type(Sequence[Union[str, bytes]]) == True
    """
    if NEW_39_TYPING:
        return (isinstance(tp, type) and issubclass(tp, Generic)
                or ((isinstance(tp, _GenericAlias) or isinstance(tp, _SpecialGenericAlias))  # NoQA E501
                and tp.__origin__ not in (Union, tuple, ClassVar, collections.abc.Callable)))  # NoQA E501
    return (isinstance(tp, type)
            and issubclass(tp, Generic)
            or isinstance(tp, _GenericAlias)
            and tp.__origin__ not in (Union, tuple, ClassVar, collections.abc.Callable))  # NoQA E501