(hint: Type)
Parse a typing hint into its type and and arguments.

    For example:

        >>> parse_hint(Union[dict, list])
        (typing.Union, [<class 'dict'>, <class 'list'>])

        >>> parse_hint(int)
        (<class 'int'>, None)
Parse a typing hint into its type and and arguments.
Parse a typing hint into its type and and arguments .
def parse_hint(hint: Type) -> Tuple[Type, Optional[List]]:
    """Parse a typing hint into its type and and arguments.

    For example:

        >>> parse_hint(Union[dict, list])
        (typing.Union, [<class 'dict'>, <class 'list'>])

        >>> parse_hint(int)
        (<class 'int'>, None)

    """
    if hasattr(hint, "__origin__"):
        # This is a type hint (eg typing.Union)
        # Filter out TypeVars such as KT & VT_co (they generally
        # indicate that no explicit hint was given)
        hint_args = [a for a in getattr(hint, "__args__", []) if not isinstance(a, TypeVar)]
        return hint.__origin__, hint_args or None
    else:
        # This is something other than a type hint
        # (e.g. an int or datetime)
        return hint, None
def parse_hint ( hint : Type ) -> Tuple [ Type , Optional [ List ] ] : if hasattr ( hint , "__origin__" ) : # This is a type hint (eg typing.Union) # Filter out TypeVars such as KT & VT_co (they generally # indicate that no explicit hint was given) hint_args = [ a for a in getattr ( hint , "__args__" , [ ] ) if not isinstance ( a , TypeVar ) ] return hint . __origin__ , hint_args or None else : # This is something other than a type hint # (e.g. an int or datetime) return hint , None