def NotSupportedOperand(klass, op, left, right=None): if right: if klass.is_ignored(left) or klass.is_ignored(right): return None return TypeErrorType.occur('not supported operand %s(%s, %s)' % (op, left.get_type().typename(), right.get_type().typename())) else: if klass.is_ignored(left): return None return TypeErrorType.occur('not supported operand %s(%s)' % (op, left.get_type().typename()))
def NoLength(klass, obj): if klass.is_ignored(obj): return None return TypeErrorType.occur('length not defined: %s' % obj)
def NotAssignable(klass, obj): if klass.is_ignored(obj): return None return TypeErrorType.occur('cannot assign item: %s' % obj)
def NotSubscriptable(klass, obj): if klass.is_ignored(obj): return None return TypeErrorType.occur('not subscriptable: %s' % obj)
def NotIterable(klass, obj): if klass.is_ignored(obj): return None return TypeErrorType.occur('not iterable: %s' % obj)
def InvalidNumOfArgs(klass, valid, nargs): if valid < nargs: return TypeErrorType.occur('too many args: %r required, %r given' % (valid, nargs)) else: return TypeErrorType.occur('too few args: %r given, %r required' % (nargs, valid))
def InvalidKeywordArgs(klass, kwd): return TypeErrorType.occur('invalid keyword argument: %s' % kwd)
def NoKeywordArg1(klass, kwd): return TypeErrorType.occur('cannot take keyword: %s' % kwd)
def NoKeywordArgs(klass): return TypeErrorType.occur('cannot take a keyword argument')
def NotInstantiatable(klass, typename): return TypeErrorType.occur('not instantiatable: %s' % typename)
def TypeCheckerError(klass, src, obj, validtype): return TypeErrorType.occur('%s (%s) must be %s' % (src, obj, validtype))