Since keyword arguments are not guaranteed to be in order, use the source
 range to order arguments so we check them in the order they were declared.
970927
def sort_args_by_position(*args)
      args.flatten.compact.sort_by do |arg|
        pos = arg.source_range.end_pos
        [pos.line, pos.offset]
      end
    end
240608
def source_range(start, end, nr_var_dict):
    

    return OrderedDict((k, e-s)
        for k, (s, e)
        in source_range_tuple(start, end, nr_var_dict).iteritems())
57116
def getrange(self, key, start, end, *, encoding=_NOTSET):
        
        if not isinstance(start, int):
            raise TypeError("start argument must be int")
        if not isinstance(end, int):
            raise TypeError("end argument must be int")
        return self.execute(b'GETRANGE', key, start, end, encoding=encoding)
55707
def take_before(node, source_part)
      range = source_range(node, source_part)
      if range
        take_while { |comment| comment.location.expression.end_pos <= range.begin_pos }
      else
        EMPTY_ARRAY
      end
    end
463923
function ensureUpperBound (range, maximum) {
  return function applyUpperBound (comparators) {
    var hasUpperBound = isBounded.comparators(comparators)
    if (hasUpperBound) return comparators
    var msg = printf(
      'Cannot determine major versions: ' +
      '"%s" is unbounded and ',
      range
    )
    if (maximum == null) {
      throw new Error(msg + 'no maximum was provided')
    }
    var upper = last(comparators)
    if (!upper.test(maximum)) {
      var explanation = printf('"%s" does not satisfy "%s"', maximum, upper.toString())
      throw new Error(msg + explanation)
    }
    return comparators.concat(new semver.Comparator('<=' + maximum))
  }
}
388677
def check_arguments(cls, passed):
        """"""
        defaults = list(cls.default_arguments().keys())
        template = ("Pass arg {argument:!r} in {cname:!r}, can be a typo? "
                    "Supported key arguments: {defaults}")
        fails = []
        for arg in passed:
            if arg not in defaults:
                warn(template.format(argument=arg,
                                     cname=cls.__name__,
                                     defaults=defaults))
                fails.append(arg)

        return any(fails)
466068
def handle_real_loop_comparison(self, args, target, upper_bound):
        
        # order is 1 for increasing loop, -1 for decreasing loop and 0 if it is
        # not known at compile time
        if len(args) <= 2:
            order = 1
        elif isinstance(args[2], ast.Num):
            order = -1 + 2 * (int(args[2].n) > 0)
        elif isinstance(args[1], ast.Num) and isinstance(args[0], ast.Num):
            order = -1 + 2 * (int(args[1].n) > int(args[0].n))
        else:
            order = 0

        comparison = "{} < {}" if order == 1 else "{} > {}"
        comparison = comparison.format(target, upper_bound)
        return comparison
789362
def getArguments(parser):
    ""
    args = parser.parse_args()
    if args.order < 0 or args.order > 5:
        parser.error('The order has to be a number between 0 and 5.')   
    return args
840104
private void checkConstructorArguments(int arguments) {
        if (arguments == 0 && (typeDef.getConstructors() == null || typeDef.getConstructors().isEmpty())) {
            return;
        }

        for (Method m : typeDef.getConstructors()) {
            int a = m.getArguments() != null ? m.getArguments().size() : 0;
            if (a == arguments) {
                return;
            }
        }
        throw new IllegalArgumentException("No constructor found for " + typeDef.getName() + " with " + arguments + " arguments.");

    }
898791
def safe_range(*args):
    
    rng = range(*args)
    if len(rng) > MAX_RANGE:
        raise OverflowError('range too big, maximum size for range is %d' %
                            MAX_RANGE)
    return rng
482269
def first(self, **kwargs):
        
        result = result = self._get(limit=1, **kwargs)
        if result:
            return result[0]
        else:
            raise self.source_class.DoesNotExist(repr(kwargs))
260817
def check_invocation(node, type)
      args = sort_args_by_position(node.args,
                                   node.splat,
                                   node.keywords.values,
                                   node.kwarg_splat)

      check_commas_after_args(args, "#{type} arguments")
    end
40991
def check_all_params_are_keyword(method):
    

    args, varargs, keywords, defaults = inspect.getargspec(method)

    # Always have self, thus the -1
    if len(args or []) - 1 != len(defaults or []):
        raise CooperativeError, "Init has positional parameters " + \
              str(args[1:])
    if varargs:
        raise CooperativeError, "Init has variadic positional parameters"
    if keywords:
        raise CooperativeError, "Init has variadic keyword parameters"
323757
def <<(arg)
            case arg
            when PositionalArgument, KeywordArgument, FlagArgument, RestArgument
                if @arguments[arg.key]
                    raise ArgumentError, "An argument with key '#{arg.key}' has already been defined"
                end
                if arg.short_key && @short_keys[arg.short_key]
                    raise ArgumentError, "The short key '#{arg.short_key}' has already been registered by the '#{
                        @short_keys[arg.short_key]}' argument"
                end
                if arg.is_a?(RestArgument) && rest_args
                    raise ArgumentError, "Only one rest argument can be defined"
                end
                @arguments[arg.key] = arg
                @short_keys[arg.short_key] = arg if arg.short_key
            else
                raise ArgumentError, "arg must be an instance of PositionalArgument, KeywordArgument, " +
                    "FlagArgument or RestArgument"
            end
        end
1311246
def lrange(self, key, start, stop, *, encoding=_NOTSET):
        
        if not isinstance(start, int):
            raise TypeError("start argument must be int")
        if not isinstance(stop, int):
            raise TypeError("stop argument must be int")
        return self.execute(b'LRANGE', key, start, stop, encoding=encoding)
776192
def default_arguments(self):
    
    d = OrderedDict()

    for arg in self._default_args:
      d.update({arg.name: arg})

    return d
688489
def CheckInputArgs(*interfaces):
    
    l = len(interfaces)
    def wrapper(func):
        def check_args(self, *args, **kw):
            for i in range(len(args)):
                if (l > i and interfaces[i].providedBy(args[i])) or interfaces[-1].providedBy(args[i]):
                    continue
                if l > i: raise TypeError, 'arg %s does not implement %s' %(args[i], interfaces[i])
                raise TypeError, 'arg %s does not implement %s' %(args[i], interfaces[-1])
            func(self, *args, **kw)
        return check_args
    return wrapper