(arg, msg, is_argument=True, module=None, *, is_class=False)
return arg
Check that the argument is a type, and return it (internal helper).

    As a special case, accept None and return type(None) instead. Also wrap strings
    into ForwardRef instances. Consider several corner cases, for example plain
    special forms like Union are not valid, while Union[int, str] is OK, etc.
    The msg argument is a human-readable error message, e.g::

        "Union[arg, ...]: arg should be a type."

    We append the repr() of the actual value (truncated to 100 chars).
Check that the argument is a type, and return it (internal helper).
Check that the argument is a type and return it ( internal helper ) .
def _type_check(arg, msg, is_argument=True, module=None, *, is_class=False):
    """Check that the argument is a type, and return it (internal helper).

    As a special case, accept None and return type(None) instead. Also wrap strings
    into ForwardRef instances. Consider several corner cases, for example plain
    special forms like Union are not valid, while Union[int, str] is OK, etc.
    The msg argument is a human-readable error message, e.g::

        "Union[arg, ...]: arg should be a type."

    We append the repr() of the actual value (truncated to 100 chars).
    """
    invalid_generic_forms = (Generic, Protocol)
    if not is_class:
        invalid_generic_forms += (ClassVar,)
        if is_argument:
            invalid_generic_forms += (Final,)

    arg = _type_convert(arg, module=module)
    if (isinstance(arg, _GenericAlias) and
            arg.__origin__ in invalid_generic_forms):
        raise TypeError(f"{arg} is not valid as type argument")
    if arg in (Any, NoReturn, Final):
        return arg
    if isinstance(arg, _SpecialForm) or arg in (Generic, Protocol):
        raise TypeError(f"Plain {arg} is not valid as type argument")
    if isinstance(arg, (type, TypeVar, ForwardRef, types.UnionType, ParamSpec)):
        return arg
    if not callable(arg):
        raise TypeError(f"{msg} Got {arg!r:.100}.")
    return arg
def _type_check ( arg , msg , is_argument = True , module = None , * , is_class = False ) : invalid_generic_forms = ( Generic , Protocol ) if not is_class : invalid_generic_forms += ( ClassVar , ) if is_argument : invalid_generic_forms += ( Final , ) arg = _type_convert ( arg , module = module ) if ( isinstance ( arg , _GenericAlias ) and arg . __origin__ in invalid_generic_forms ) : raise TypeError ( f"{arg} is not valid as type argument" ) if arg in ( Any , NoReturn , Final ) : return arg if isinstance ( arg , _SpecialForm ) or arg in ( Generic , Protocol ) : raise TypeError ( f"Plain {arg} is not valid as type argument" ) if isinstance ( arg , ( type , TypeVar , ForwardRef , types . UnionType , ParamSpec ) ) : return arg if not callable ( arg ) : raise TypeError ( f"{msg} Got {arg!r:.100}." ) return arg