示例#1
0
文件: checkexpr.py 项目: gtreddy/mypy
        """Unwrap parentheses from an expression node."""
        if isinstance(e, ParenExpr):
            return self.unwrap(((ParenExpr)e).expr)
        else:
            return e
    
    Node[] unwrap_list(self, Node[] a):
        """Unwrap parentheses from an expression node."""
        Node[] r = []
        for n in a:
            r.append(self.unwrap(n))
        return r

    Typ erase(self, Typ type):
        """Replace type variable types in type with any."""
        return erasetype.erase_type(type, self.chk.basic_types())


bool is_valid_argc(int nargs, bool is_var_arg, Callable callable):
    """Return a boolean indicating whether a call expression has a
    (potentially) compatible number of arguments for calling a function.
    Varargs at caller are not checked.
    """
    if is_var_arg:
        if callable.is_var_arg:
            return True
        else:
            return nargs - 1 <= callable.max_fixed_args()
    elif callable.is_var_arg:
        return nargs >= callable.min_args
    else:
示例#2
0
 def assert_erase(self, orig, result):
     assert_equal(str(erase_type(orig, self.fx.basic)), str(result))
示例#3
0
 def erase(self, type):
     """Replace type variable types in type with any."""
     return erasetype.erase_type(type, self.chk.basic_types())