def check_spec(self, pos_args, kwargs=None):
if kwargs is None:<EOL><INDENT>kwargs = {}<EOL><DEDENT>if self.varargs is not None or self.kwargs is not None:<EOL><INDENT>raise InternalError("<STR_LIT>")<EOL><DEDENT>missing = object()<EOL>arg_vals = [missing]*len(self.arg_names)<EOL>kw_indices = {name: i for i, name in enumerate(self.arg_names)}<EOL>for i, arg in enumerate(pos_args):<EOL><INDENT>if i >= len(arg_vals):<EOL><INDENT>raise ArgumentError("<STR_LIT>" % str(arg))<EOL><DEDENT>arg_vals[i] = arg<EOL><DEDENT>for arg, val in kwargs.items():<EOL><INDENT>index = kw_indices.get(arg)<EOL>if index is None:<EOL><INDENT>raise ArgumentError("<STR_LIT>" % arg)<EOL><DEDENT>if arg_vals[index] is not missing:<EOL><INDENT>raise ValidationError("<STR_LIT>" % arg)<EOL><DEDENT>arg_vals[index] = val<EOL><DEDENT>if len(self.arg_defaults) > <NUM_LIT:0>:<EOL><INDENT>for i in range(<NUM_LIT:0>, len(self.arg_defaults)):<EOL><INDENT>neg_index = -len(self.arg_defaults) + i<EOL>if arg_vals[neg_index] is missing:<EOL><INDENT>arg_vals[neg_index] = self.arg_defaults[i]<EOL><DEDENT><DEDENT><DEDENT>if missing in arg_vals:<EOL><INDENT>index = arg_vals.index(missing)<EOL>raise ArgumentError("<STR_LIT>" % (index, self.arg_names[index]))<EOL><DEDENT>return {name: val for name, val in zip(self.arg_names, arg_vals)}<EOL>
Check if there are any missing or duplicate arguments.

        Args:
            pos_args (list): A list of arguments that will be passed as positional
                arguments.
            kwargs (dict): A dictionary of the keyword arguments that will be passed.

        Returns:
            dict: A dictionary of argument name to argument value, pulled from either
                the value passed or the default value if no argument is passed.

        Raises:
            ArgumentError: If a positional or keyword argument does not fit in the spec.
            ValidationError: If an argument is passed twice.