

def linearize_arg_types(fn, args):
    "\n  Given a function object which might be one of:\n    (1) a closure type\n    (2) the name of an untyped function\n    (3) an untyped fn object\n  and some argument types which might\n    (1) a list\n    (2) a tuple\n    (3) an ActualArgs object\n  linearize the argument types with respect to\n  the untyped function's argument order and return\n  both the untyped function and list of arguments\n  "
    (untyped_fundef, closure_args) = unpack_closure(fn)
    if isinstance(args, (list, tuple)):
        args = ActualArgs(args)
    if (not isinstance(untyped_fundef.args, FormalArgs)):
        assert False, ('Expected function %s to have FormalArgs' % untyped_fundef.name)
    else:
        formals = untyped_fundef.args
    if (len(closure_args) > 0):
        args = args.prepend_positional(closure_args)

    def keyword_fn(_, v):
        return type_conv.typeof(v)
    try:
        (linear_args, extra) = formals.linearize_values(args, keyword_fn=keyword_fn)
    except UnexpectedKeyword as e:
        e.fn_name = untyped_fundef.name
        raise
    return (untyped_fundef, tuple((linear_args + extra)))

dataset/ETHPy150Open iskandr/parakeet/parakeet/type_inference/linearize_args.py linearize_arg_types/original