Checking the inspector is never called with partial SinonMatcher(args/kwargs)
        Args: SinonSpy, args/kwargs
555851
def neverCalledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name
        
        cls.__is_spy(spy)
        if not (spy.neverCalledWithMatch(*args, **kwargs)):
            raise cls.failException(cls.message)
342491
def args_match(m_args, m_kwargs, default, *args, **kwargs):
    
    if len(m_args) > len(args):
        return False
    for m_arg, arg in zip(m_args, args):
        matches = arg_match(m_arg, arg, eq)
        if not matches or matches is InvalidArg:
            return False  # bail out

    if m_kwargs:
        for name, m_arg in m_kwargs.items():
            name, comparator = arg_comparitor(name)
            arg = kwargs.get(name)
            if not arg_match(m_arg, arg, comparator, default):
                return False  # bail out
    return True
783260
def kwargs_only(func):
    
    if hasattr(inspect, 'signature'):  # pragma: no cover
        # Python 3
        signature = inspect.signature(func)
        first_arg_name = list(signature.parameters.keys())[0]
    else:  # pragma: no cover
        # Python 2
        signature = inspect.getargspec(func)
        first_arg_name = signature.args[0]

    if first_arg_name in ('self', 'cls'):
        allowable_args = 1
    else:
        allowable_args = 0

    @wraps(func)
    def wrapper(*args, **kwargs):
        if len(args) > allowable_args:
            raise TypeError("{} should only be called with keyword args".format(func.__name__))
        return func(*args, **kwargs)

    return wrapper
1303532
def takes_kwargs(obj) -> bool:
    
    if inspect.isclass(obj):
        signature = inspect.signature(obj.__init__)
    elif inspect.ismethod(obj) or inspect.isfunction(obj):
        signature = inspect.signature(obj)
    else:
        raise ConfigurationError(f"object {obj} is not callable")
    return bool(any([p.kind == inspect.Parameter.VAR_KEYWORD  # type: ignore
                     for p in signature.parameters.values()]))
816027
def match(self, method, path):
        
        segments = path.split('/')
        while len(segments):
            index = '/'.join(segments)
            if index in self.__idx__:
                handler, params = self.match_rule(method, path,
                                                  self.__idx__[index])
                if handler:
                    return handler, params
            segments.pop()
        return None, None
1188423
def calledTwice(cls, spy): #pylint: disable=invalid-name
        
        cls.__is_spy(spy)
        if not (spy.calledTwice):
            raise cls.failException(cls.message)
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
43675
def _try_methods(methods, to_find=None):
    # type: (list, Optional[str]) -> Optional[str]
    
    found = None
    for m in methods:
        try:
            if isinstance(m, tuple):
                for arg in m[3]:  # list(str)
                    if DEBUG:
                        log.debug("Trying: '%s %s'", m[2], arg)
                    # Arguments: (regex, _popen(command, arg), regex index)
                    found = _search(m[0], _popen(m[2], arg), m[1])
                    if DEBUG:
                        log.debug("Result: %s\n", found)
                    if found:  # Skip remaining args AND remaining methods
                        break
            elif callable(m):
                if DEBUG:
                    log.debug("Trying: '%s' (to_find: '%s')", m.__name__, str(to_find))
                if to_find is not None:
                    found = m(to_find)
                else:
                    found = m()
                if DEBUG:
                    log.debug("Result: %s\n", found)
            else:
                log.critical("Invalid type '%s' for method '%s'", type(m), str(m))
        except Exception as ex:
            if DEBUG:
                log.debug("Exception: %s", str(ex))
            if DEBUG >= 2:
                log.debug(traceback.format_exc())
            continue
        if found:  # Skip remaining methods
            break
    return found
202126
def has_arg(fn, arg_name):
    
    if sys.version_info < (3,):
        if isinstance(fn, types.FunctionType) or isinstance(fn, types.MethodType):
            arg_spec = inspect.getargspec(fn)
        else:
            try:
                arg_spec = inspect.getargspec(fn.__call__)
            except AttributeError:
                return False
        return (arg_name in arg_spec.args)
    elif sys.version_info < (3, 6):
        arg_spec = inspect.getfullargspec(fn)
        return (arg_name in arg_spec.args or
                arg_name in arg_spec.kwonlyargs)
    else:
        try:
            signature = inspect.signature(fn)
        except ValueError:
            # handling Cython
            signature = inspect.signature(fn.__call__)
        parameter = signature.parameters.get(arg_name)
        if parameter is None:
            return False
        return (parameter.kind in (inspect.Parameter.POSITIONAL_OR_KEYWORD,
                                   inspect.Parameter.KEYWORD_ONLY))
986189
def match(self, *args, **kwargs):
        
        return self._any_args or \
            self._arguments_rule.validate(*args, **kwargs)
1103366
def defaultAutoRangeMethods(inspector, intialItems=None):
    
    rangeFunctions = OrderedDict({} if intialItems is None else intialItems)
    rangeFunctions['use all data'] = partial(inspectorDataRange, inspector, 0.0)
    for percentage in [0.1, 0.2, 0.5, 1, 2, 5, 10, 20]:
        label = "discard {}%".format(percentage)
        rangeFunctions[label] = partial(inspectorDataRange, inspector, percentage)
    return rangeFunctions
685099
def _any_would_run(func, filenames, *args):
    """"""
    if os.environ.get("_POLYSQUARE_GENERIC_FILE_LINTER_NO_STAMPING", None):
        return True

    for filename in filenames:
        # suppress(E204)
        stamp_args, stamp_kwargs = _run_lint_on_file_stamped_args(filename,
                                                                  *args,
                                                                  **{})
        dependency = jobstamp.out_of_date(func,
                                          *stamp_args,
                                          **stamp_kwargs)

        if dependency:
            return True

    return False
1270380
def __args_check(self, valid, args=None, kwargs=None):
        '''
        
        '''
        if not isinstance(valid, list):
            valid = [valid]
        for cond in valid:
            if not isinstance(cond, dict):
                # Invalid argument
                continue
            # whitelist args, kwargs
            cond_args = cond.get('args', [])
            good = True
            for i, cond_arg in enumerate(cond_args):
                if args is None or len(args) <= i:
                    good = False
                    break
                if cond_arg is None:  # None == '.*' i.e. allow any
                    continue
                if not self.match_check(cond_arg, six.text_type(args[i])):
                    good = False
                    break
            if not good:
                continue
            # Check kwargs
            cond_kwargs = cond.get('kwargs', {})
            for k, v in six.iteritems(cond_kwargs):
                if kwargs is None or k not in kwargs:
                    good = False
                    break
                if v is None:  # None == '.*' i.e. allow any
                    continue
                if not self.match_check(v, six.text_type(kwargs[k])):
                    good = False
                    break
            if good:
                return True
        return False
676044
def accepts_kwarg(func, kwarg):
    
    signature = inspect.signature(func)
    try:
        signature.bind_partial(**{kwarg: None})
        return True
    except TypeError:
        return False
1065317
def checker(func: Callable) -> Callable:
    

    def func_wrapper(*args, **kwargs):
        try:
            func(*args, **kwargs)
            return True
        except AssertionError:
            raise CiVerificationError(
                'The verification check for the environment did not pass.'
            )

    return func_wrapper
1177471
def not_called_with(self, *args, **kwargs):
        
        call = Call(*args, **kwargs)
        if call in calls(self.spy):
            raise VerificationError(
                'expected %s to not be called with %s, but it was' % (
                    self.spy, call.formatted_args))
        return True
1059405
def search(query, delegate)
      validate_delegate(delegate)

      delegate.inspector_started_query(query, inspector)
      url = url_for_request query

      begin
        results = get_api_results(url)
      rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
        delegate.inspector_could_not_create_report(e, query, inspector)
        return
      end

      report = parse_results query, results

      # TODO: progress callback

      if report.issues.any?
        if self.using_deprecated_method
          delegate.inspector_successfully_recieved_report(report, inspector)
        else
          delegate.inspector_successfully_received_report(report, inspector)
        end
      else
        # rubocop:disable Style/IfInsideElse
        if self.using_deprecated_method
          delegate.inspector_recieved_empty_report(report, inspector)
        else
          delegate.inspector_received_empty_report(report, inspector)
        end
        # rubocop:enable Style/IfInsideElse
      end

      report
    end