def get_mypy_type_of_runtime_value(runtime: Any) -> Optional[mypy.types.Type]:
    "Returns a mypy type object representing the type of ``runtime``.\n\n    Returns None if we can't find something that works.\n\n    "
    if (runtime is None):
        return mypy.types.NoneType()
    if isinstance(runtime, property):
        return None

    def anytype() -> mypy.types.AnyType:
        return mypy.types.AnyType(mypy.types.TypeOfAny.unannotated)
    if isinstance(runtime, (types.FunctionType, types.BuiltinFunctionType, types.MethodType, types.BuiltinMethodType)):
        builtins = get_stub('builtins')
        assert (builtins is not None)
        type_info = builtins.names['function'].node
        assert isinstance(type_info, nodes.TypeInfo)
        fallback = mypy.types.Instance(type_info, [anytype()])
        try:
            signature = inspect.signature(runtime)
            arg_types = []
            arg_kinds = []
            arg_names = []
            for arg in signature.parameters.values():
                arg_types.append(anytype())
                arg_names.append((None if (arg.kind == inspect.Parameter.POSITIONAL_ONLY) else arg.name))
                has_default = (arg.default == inspect.Parameter.empty)
                if (arg.kind == inspect.Parameter.POSITIONAL_ONLY):
                    arg_kinds.append((nodes.ARG_POS if has_default else nodes.ARG_OPT))
                elif (arg.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD):
                    arg_kinds.append((nodes.ARG_POS if has_default else nodes.ARG_OPT))
                elif (arg.kind == inspect.Parameter.KEYWORD_ONLY):
                    arg_kinds.append((nodes.ARG_NAMED if has_default else nodes.ARG_NAMED_OPT))
                elif (arg.kind == inspect.Parameter.VAR_POSITIONAL):
                    arg_kinds.append(nodes.ARG_STAR)
                elif (arg.kind == inspect.Parameter.VAR_KEYWORD):
                    arg_kinds.append(nodes.ARG_STAR2)
                else:
                    raise AssertionError
        except ValueError:
            arg_types = [anytype(), anytype()]
            arg_kinds = [nodes.ARG_STAR, nodes.ARG_STAR2]
            arg_names = [None, None]
        return mypy.types.CallableType(arg_types, arg_kinds, arg_names, ret_type=anytype(), fallback=fallback, is_ellipsis_args=True)
    stub = get_stub(type(runtime).__module__)
    if (stub is None):
        return None
    type_name = type(runtime).__name__
    if (type_name not in stub.names):
        return None
    type_info = stub.names[type_name].node
    if isinstance(type_info, nodes.Var):
        return type_info.type
    if (not isinstance(type_info, nodes.TypeInfo)):
        return None
    if isinstance(runtime, tuple):
        optional_items = [get_mypy_type_of_runtime_value(v) for v in runtime]
        items = [(i if (i is not None) else anytype()) for i in optional_items]
        fallback = mypy.types.Instance(type_info, [anytype()])
        return mypy.types.TupleType(items, fallback)
    fallback = mypy.types.Instance(type_info, [anytype() for _ in type_info.type_vars])
    try:
        return mypy.types.LiteralType(value=runtime, fallback=fallback)
    except TypeError:
        return fallback
Returns a mypy type object representing the type of ``runtime``.

Returns None if we can't find something that works.
def get_mypy_type_of_runtime_value(runtime: Any) -> Optional[mypy.types.Type]:
    "Returns a mypy type object representing the type of ``runtime``.\n\n    Returns None if we can't find something that works.\n\n    "
    if (runtime is None):
        return mypy.types.NoneType()
    if isinstance(runtime, property):
        return None

    def anytype() -> mypy.types.AnyType:
        return mypy.types.AnyType(mypy.types.TypeOfAny.unannotated)
    if isinstance(runtime, (types.FunctionType, types.BuiltinFunctionType, types.MethodType, types.BuiltinMethodType)):
        builtins = get_stub('builtins')
        assert (builtins is not None)
        type_info = builtins.names['function'].node
        assert isinstance(type_info, nodes.TypeInfo)
        fallback = mypy.types.Instance(type_info, [anytype()])
        try:
            signature = inspect.signature(runtime)
            arg_types = []
            arg_kinds = []
            arg_names = []
            for arg in signature.parameters.values():
                arg_types.append(anytype())
                arg_names.append((None if (arg.kind == inspect.Parameter.POSITIONAL_ONLY) else arg.name))
                has_default = (arg.default == inspect.Parameter.empty)
                if (arg.kind == inspect.Parameter.POSITIONAL_ONLY):
                    arg_kinds.append((nodes.ARG_POS if has_default else nodes.ARG_OPT))
                elif (arg.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD):
                    arg_kinds.append((nodes.ARG_POS if has_default else nodes.ARG_OPT))
                elif (arg.kind == inspect.Parameter.KEYWORD_ONLY):
                    arg_kinds.append((nodes.ARG_NAMED if has_default else nodes.ARG_NAMED_OPT))
                elif (arg.kind == inspect.Parameter.VAR_POSITIONAL):
                    arg_kinds.append(nodes.ARG_STAR)
                elif (arg.kind == inspect.Parameter.VAR_KEYWORD):
                    arg_kinds.append(nodes.ARG_STAR2)
                else:
                    raise AssertionError
        except ValueError:
            arg_types = [anytype(), anytype()]
            arg_kinds = [nodes.ARG_STAR, nodes.ARG_STAR2]
            arg_names = [None, None]
        return mypy.types.CallableType(arg_types, arg_kinds, arg_names, ret_type=anytype(), fallback=fallback, is_ellipsis_args=True)
    stub = get_stub(type(runtime).__module__)
    if (stub is None):
        return None
    type_name = type(runtime).__name__
    if (type_name not in stub.names):
        return None
    type_info = stub.names[type_name].node
    if isinstance(type_info, nodes.Var):
        return type_info.type
    if (not isinstance(type_info, nodes.TypeInfo)):
        return None
    if isinstance(runtime, tuple):
        optional_items = [get_mypy_type_of_runtime_value(v) for v in runtime]
        items = [(i if (i is not None) else anytype()) for i in optional_items]
        fallback = mypy.types.Instance(type_info, [anytype()])
        return mypy.types.TupleType(items, fallback)
    fallback = mypy.types.Instance(type_info, [anytype() for _ in type_info.type_vars])
    try:
        return mypy.types.LiteralType(value=runtime, fallback=fallback)
    except TypeError:
        return fallback