Check if an object is a Cython function or method
340906
def is_cython(obj):
    """"""

    # TODO(suo): We could split these into two functions, one for Cython
    # functions and another for Cython methods.
    # TODO(suo): There doesn't appear to be a Cython function 'type' we can
    # check against via isinstance. Please correct me if I'm wrong.
    def check_cython(x):
        return type(x).__name__ == "cython_function_or_method"

    # Check if function or method, respectively
    return check_cython(obj) or \
        (hasattr(obj, "__func__") and check_cython(obj.__func__))
707357
def check_is_injectable(func):
    
    @wraps(func)
    def wrapper(**kwargs):
        name = kwargs['inj_name']
        if not orca.is_injectable(name):
            abort(404)
        return func(**kwargs)
    return wrapper
724772
function isFunctionBasic(inputArg) {
            var isFn = toClass(inputArg) === classFunction,
                type;

            if (!isFn && inputArg !== null) {
                type = typeof inputArg;
                if ((type === 'function' || type === 'object') &&
                        ('constructor' in inputArg) &&
                        ('call' in inputArg) &&
                        ('apply' in inputArg) &&
                        ('length' in inputArg) &&
                        typeof inputArg.length === 'number') {

                    isFn = true;
                }
            }

            return isFn;
        }
1250319
def is_leaf(obj):
    '''
        
    '''
    if(is_dict(obj)):
        length = obj.__len__()
        if(length == 0):
            return(True)
        else:
            return(False)
    else:
        return(True)
166725
def is_member_function(f):
    
    f_args, f_varargs, f_varkw, f_defaults = inspect.getargspec(f)
    return 1 if 'self' in f_args else 0
1124423
def infer_returned_object(pyfunction, args):
    """"""
    object_info = pyfunction.pycore.object_info
    result = object_info.get_exact_returned(pyfunction, args)
    if result is not None:
        return result
    result = _infer_returned(pyfunction, args)
    if result is not None:
        if args and pyfunction.get_module().get_resource() is not None:
            params = args.get_arguments(
                pyfunction.get_param_names(special_args=False))
            object_info.function_called(pyfunction, params, result)
        return result
    result = object_info.get_returned(pyfunction, args)
    if result is not None:
        return result
    hint_return = get_type_hinting_factory(pyfunction.pycore.project).make_return_provider()
    type_ = hint_return(pyfunction)
    if type_ is not None:
        return rope.base.pyobjects.PyObject(type_)
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()]))
380273
def is_defined_by_module(item, module, parent=None):
    
    flag = False
    if isinstance(item, types.ModuleType):
        if not hasattr(item, '__file__'):
            try:
                # hack for cv2 and xfeatures2d
                import utool as ut
                name = ut.get_modname_from_modpath(module.__file__)
                flag = name in str(item)
            except:
                flag = False
        else:
            item_modpath = os.path.realpath(dirname(item.__file__))
            mod_fpath = module.__file__.replace('.pyc', '.py')
            if not mod_fpath.endswith('__init__.py'):
                flag = False
            else:
                modpath = os.path.realpath(dirname(mod_fpath))
                modpath = modpath.replace('.pyc', '.py')
                flag = item_modpath.startswith(modpath)
    elif hasattr(item, '_utinfo'):
        # Capture case where there is a utool wrapper
        orig_func = item._utinfo['orig_func']
        flag = is_defined_by_module(orig_func, module, parent)
    else:
        if isinstance(item, staticmethod):
            # static methods are a wrapper around a function
            item = item.__func__
        try:
            func_globals = meta_util_six.get_funcglobals(item)
            func_module_name = func_globals['__name__']
            if func_module_name == 'line_profiler':
                valid_names = dir(module)
                if parent is not None:
                    valid_names += dir(parent)
                if item.func_name in valid_names:
                    # hack to prevent small names
                    #if len(item.func_name) > 8:
                    if len(item.func_name) > 6:
                        flag = True
            elif func_module_name == module.__name__:
                flag = True
        except  AttributeError:
            if hasattr(item, '__module__'):
                flag = item.__module__ == module.__name__
    return flag
1130739
def has_method(obj, method_name):
    '''
    
    '''
    if method_name in dir(obj):
        return True

    log.error('Method \'%s\' not yet supported!', method_name)
    return False
1048217
def is_cython_or_generator(fn):
    """"""
    if hasattr(fn, "__func__"):
        fn = fn.__func__  # Class method, static method
    if inspect.isgeneratorfunction(fn):
        return True
    name = type(fn).__name__
    return (
        name == "generator"
        or name == "method_descriptor"
        or name == "cython_function_or_method"
        or name == "builtin_function_or_method"
    )
1069961
def isfunc(x):
    
    return any([
        inspect.isfunction(x) and not asyncio.iscoroutinefunction(x),
        inspect.ismethod(x) and not asyncio.iscoroutinefunction(x)
    ])
1104087
def is_classmethod(meth):
    
    if inspect.ismethoddescriptor(meth):
        return isinstance(meth, classmethod)
    if not inspect.ismethod(meth):
        return False
    if not inspect.isclass(meth.__self__):
        return False
    if not hasattr(meth.__self__, meth.__name__):
        return False
    return meth == getattr(meth.__self__, meth.__name__)
102699
def _class_defining_method(meth):  # pragma: no cover
    '''
    '''
    if inspect.ismethod(meth):
        for cls in inspect.getmro(meth.__self__.__class__):
            if cls.__dict__.get(meth.__name__) is meth:
                return '{}.{}'.format(cls.__module__, cls.__name__)
        meth = meth.__func__
    if inspect.isfunction(meth):
        module = meth.__qualname__.split('.<locals>', 1)[0]
        cls = getattr(inspect.getmodule(meth), module.rsplit('.', 1)[0])
        if isinstance(cls, type):
            return '{}.{}'.format(cls.__module__, cls.__name__)
503642
def _is_deprecated(func):
    """"""
    if sys.version_info < (3, 5):
        raise NotImplementedError("This is only available for python3.5 "
                                  "or above")
    closures = getattr(func, '__closure__', [])
    if closures is None:
        closures = []
    is_deprecated = ('deprecated' in ''.join([c.cell_contents
                                              for c in closures
                                              if isinstance(c.cell_contents, str)]))
    return is_deprecated
1199975
def is_method(func):
    
    func0 = _actualfunc(func)
    argNames = getargnames(getargspecs(func0))
    if len(argNames) > 0:
        if argNames[0] == 'self':
            if inspect.ismethod(func):
                return True
            elif sys.version_info.major >= 3:
                # In Python3 there are no unbound methods, so we count as method,
                # if first arg is called 'self' 
                return True
            else:
                _warn_argname('is_method encountered non-method declaring self',
                        func0, False, False, None)
        else:
            return inspect.ismethod(func)
    return False
20669
def is_mod_function(mod, fun):
    
    return inspect.isfunction(fun) and inspect.getmodule(fun) == mod
1287215
function isCallToMethod(node, version, method) {
    return methodDataUtil.isAliasOfMethod(version, method, astUtil.getMethodName(node))
}