Return True iff this method is a magic method (e.g., `__str__`).
430516
def is_magic(self):
        """"""
        return (self.name.startswith('__') and
                self.name.endswith('__') and
                self.name not in VARIADIC_MAGIC_METHODS)
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__)
919957
def is_attrsignal_handler(descriptor, signal_name, cb, *, defer=False):
    
    try:
        handlers = get_magic_attr(cb)
    except AttributeError:
        return False

    return _attrsignal_spec(descriptor, signal_name, cb, defer) in handlers
396650
def is_class(data):
    

    try:
        with unpack(data) as up:
            magic = up.unpack_struct(_BBBB)

        return magic == JAVA_CLASS_MAGIC

    except UnpackException:
        return False
573075
def is_attribute(method, name=None):
    
    if name is None:
        name = method.__name__
    method.is_attribute = True
    method.name = name
    return method
680467
def _get_file_magic_name(self, buffer):
        
        default = "Unknown"

        # Faster way, test once, return default.
        if self.__no_magic:
            return default

        try:
            # Magic is optional
            import magic
        except ImportError:
            self.__no_magic = True
            log.warning("No Magic library was found on your system.")
            return default
        except TypeError as e:
            self.__no_magic = True
            log.warning("It looks like you have the magic python package installed but not the magic library itself!")
            log.warning("Error from magic library: %s", e)
            log.warning("Please follow the installation instructions at https://github.com/ahupp/python-magic/#installation")
            return default

        try:
            # There are several implementations of magic,
            # unfortunately all called magic
            # We use this one: https://github.com/ahupp/python-magic/
            getattr(magic, "MagicException")
        except AttributeError:
            self.__no_magic = True
            log.warning("Not the correct Magic library was found on your system. Please install python-magic!")
            return default

        try:
            ftype = magic.from_buffer(buffer[:1024])
        except magic.MagicError as e:
            log.exception("Error getting the magic type: %s", e)
            return default

        if not ftype:
            return default
        else:
            return self._patch_magic(buffer, ftype)
877212
def is_simple_callable(obj):
    
    function = inspect.isfunction(obj)
    method = inspect.ismethod(obj)

    if not (function or method):
        return False

    args, _, _, defaults = inspect.getargspec(obj)
    len_args = len(args) if function else len(args) - 1
    len_defaults = len(defaults) if defaults else 0
    return len_args <= len_defaults
1305480
def magic_help(self, line):
        
        line = line.strip()
        if not line:
            for magic in self.magics:
                stream_content = {'name': 'stdout', 'text': "%{}\n".format(magic)}
                self.send_response(self.iopub_socket, 'stream', stream_content)
        elif line in self.magics:
            # its a magic
            stream_content = {'name': 'stdout', 'text': "{}\n{}".format(line, self.magics[line].__doc__)}
            self.send_response(self.iopub_socket, 'stream', stream_content)
        elif line in self.interpreter.ops:
            # it's an instruction
            stream_content = {'name': 'stdout', 'text': "{}\n{}".format(line, self.interpreter.ops[line].__doc__)}
            self.send_response(self.iopub_socket, 'stream', stream_content)
        else:
            stream_content = {'name': 'stderr', 'text': "'{}' not a known magic or instruction".format(line)}
            self.send_response(self.iopub_socket, 'stream', stream_content)
210087
def _validate_class_definition(meta, classname, bases, dict_):
        
        # let the BaseMatcher class be created without hassle
        if meta._is_base_matcher_class_definition(classname, dict_):
            return

        # ensure that no important magic methods are being overridden
        for name, member in dict_.items():
            if not (name.startswith('__') and name.endswith('__')):
                continue

            # check if it's not a whitelisted magic method name
            name = name[2:-2]
            if not name:
                continue  # unlikely case of a ``____`` function
            if name not in meta._list_magic_methods(BaseMatcher):
                continue
            if name in meta.USER_OVERRIDABLE_MAGIC_METHODS:
                continue

            # non-function attributes, like __slots__, are harmless
            if not inspect.isfunction(member):
                continue

            # classes in this very module are exempt, since they define
            # the very behavior of matchers we want to protect
            if member.__module__ == __name__:
                continue

            raise RuntimeError(
                "matcher class %s cannot override the __%s__ method" % (
                    classname, name))
727592
def is_proxy(elt):
    

    if ismethod(elt):
        elt = get_method_function(elt)

    result = hasattr(elt, __PROXIFIED__)

    return result
1056046
def magic_fields(self):
        """"""
        return {f:v for f, v in self.fields.items() if f.startswith('_')}
767974
def is_str(arg):
    '''
     
    '''
    return (isinstance(arg, six.string_types) or
            is_npscalar(arg, 'string') or
            is_npvalue(arg, 'string'))
922407
static boolean isSetterMethod(final Method method) {
        return method.getName().startsWith(SETTER_METHOD_PREFIX)
                &&
                Builder.class.isAssignableFrom(method.getReturnType())
                &&
                !method.isVarArgs()
                &&
                method.getParameterTypes().length == 1;
    }
20669
def is_mod_function(mod, fun):
    
    return inspect.isfunction(fun) and inspect.getmodule(fun) == mod
771663
def is_magic(line, language, global_escape_flag=True):
    """"""
    if language in ['octave', 'matlab']:
        return False
    if _MAGIC_FORCE_ESC_RE.get(language, _MAGIC_FORCE_ESC_RE['python']).match(line):
        return True
    if not global_escape_flag or _MAGIC_NOT_ESC_RE.get(language, _MAGIC_NOT_ESC_RE['python']).match(line):
        return False
    if _MAGIC_RE.get(language, _MAGIC_RE['python']).match(line):
        return True
    if language != 'python':
        return False
    if _PYTHON_HELP_OR_BASH_CMD.match(line):
        return True
    return _PYTHON_MAGIC_CMD.match(line)
417684
private static boolean goodMethod(Method method) {
    int modifiers = method.getModifiers();
    if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers)) return false;
    // Skip bridge methods generated method by compiler
    // For example. CompareTo(Some) and CompareTo(Object).
    if (method.isBridge()) return false;
    // Skip method in Object
    String methodName = method.getName();
    if (method.getParameterTypes().length == 0
        && (methodName.equals("hashCode") || methodName.equals("toString"))) return false;
    if (method.getParameterTypes().length == 1 & methodName.equals("equals")) return false;
    return true;
  }
58889
def _check_methods(cls, subclass):  # pylint: disable=too-many-branches
    

    for meth, methobj in cls.__abstractmethods__.items():

        # Need to get attribute from dictionary for instance tests to work
        for base in subclass.__mro__:  # pragma: no branch
            if meth in base.__dict__:
                submethobj = base.__dict__[meth]
                break

        # If we found our abstract method, we didn't find anything
        if submethobj is methobj:
            submethobj = UNDEFINED

        # Determine if we have the right method type
        result = None
        bad_arg_spec = 'Argument spec does not match parent for method %s'

        # pylint: disable=deprecated-method
        if isinstance(methobj, property):
            if submethobj is UNDEFINED or not isinstance(submethobj, property):
                result = Result(False, 'Does not contain required property (%s)' % meth, 210)

        elif isinstance(methobj, staticmethod):
            if submethobj is UNDEFINED or not isinstance(submethobj, staticmethod):
                result = Result(False, 'Does not contain required static method (%s)' % meth, 211)
            elif PY26:  # pragma: no cover
                if getfullargspec(methobj.__get__(True)) != \
                   getfullargspec(submethobj.__get__(True)):
                    result = Result(False, bad_arg_spec % meth, 220)
            elif getfullargspec(methobj.__func__) != getfullargspec(submethobj.__func__):
                result = Result(False, bad_arg_spec % meth, 220)

        elif isinstance(methobj, classmethod):
            if submethobj is UNDEFINED or not isinstance(submethobj, classmethod):
                result = Result(False, 'Does not contain required class method (%s)' % meth, 212)
            elif PY26:  # pragma: no cover
                if getfullargspec(methobj.__get__(True).__func__) != \
                   getfullargspec(submethobj.__get__(True).__func__):
                    result = Result(False, bad_arg_spec % meth, 220)
            elif getfullargspec(methobj.__func__) != getfullargspec(submethobj.__func__):
                result = Result(False, bad_arg_spec % meth, 220)

        elif isfunction(methobj):
            if submethobj is UNDEFINED or not isfunction(submethobj):
                result = Result(False, 'Does not contain required method (%s)' % meth, 213)
            elif getfullargspec(methobj) != getfullargspec(submethobj):
                result = Result(False, bad_arg_spec % meth, 220)

        # If it's not a type we're specifically checking, just check for existence
        elif submethobj is UNDEFINED:
            result = Result(False, 'Does not contain required attribute (%s)' % meth, 214)

        if result:
            return result

    return Result(True, None, 0)