pylint/checkers/typecheck.py
def _emit_no_member(node, owner, owner_name, ignored_mixins=True, ignored_none=True):
    """Try to see if no-member should be emitted for the given owner.

    The following cases are ignored:

        * the owner is a function and it has decorators.
        * the owner is an instance and it has __getattr__, __getattribute__ implemented
        * the module is explicitly ignored from no-member checks
        * the owner is a class and the name can be found in its metaclass.
        * The access node is protected by an except handler, which handles
          AttributeError, Exception or bare except.
    """
    # pylint: disable=too-many-return-statements
    if node_ignores_exception(node, AttributeError):
        return False
    if ignored_none and isinstance(owner, astroid.Const) and owner.value is None:
        return False
    if is_super(owner) or getattr(owner, "type", None) == "metaclass":
        return False
    if ignored_mixins and owner_name[-5:].lower() == "mixin":
        return False
    if isinstance(owner, astroid.FunctionDef) and owner.decorators:
        return False
    if isinstance(owner, (astroid.Instance, astroid.ClassDef)):
        if owner.has_dynamic_getattr():
            # Issue #2565: Don't ignore enums, as they have a `__getattr__` but it's not
            # invoked at this point.
            try:
                metaclass = owner.metaclass()
            except exceptions.MroError:
                return False
            if metaclass:
                return metaclass.qname() == "enum.EnumMeta"
            return False
        if not has_known_bases(owner):
            return False
    if isinstance(owner, objects.Super):
        # Verify if we are dealing with an invalid Super object.
        # If it is invalid, then there's no point in checking that
        # it has the required attribute. Also, don't fail if the
        # MRO is invalid.
        try:
            owner.super_mro()
        except (exceptions.MroError, exceptions.SuperError):
            return False
        if not all(map(has_known_bases, owner.type.mro())):
            return False
    if isinstance(owner, astroid.Module):
        try:
            owner.getattr("__getattr__")
            return False
        except astroid.NotFoundError:
            pass
    if node.attrname.startswith("_" + owner_name):
        # Test if an attribute has been mangled ('private' attribute)
        unmangled_name = node.attrname.split("_" + owner_name)[-1]
        try:
            if owner.getattr(unmangled_name, context=None) is not None:
                return False
        except astroid.NotFoundError:
            return True
    return True
def _emit_no_member(node, owner, owner_name, ignored_mixins=True, ignored_none=True):
    # pylint: disable=too-many-return-statements
    if node_ignores_exception(node, AttributeError):
        return False
    if ignored_none and isinstance(owner, astroid.Const) and owner.value is None:
        return False
    if is_super(owner) or getattr(owner, "type", None) == "metaclass":
        return False
    if ignored_mixins and owner_name[-5:].lower() == "mixin":
        return False
    if isinstance(owner, astroid.FunctionDef) and owner.decorators:
        return False
    if isinstance(owner, (astroid.Instance, astroid.ClassDef)):
        if owner.has_dynamic_getattr():
            # Issue #2565: Don't ignore enums, as they have a `__getattr__` but it's not
            # invoked at this point.
            try:
                metaclass = owner.metaclass()
            except exceptions.MroError:
                return False
            if metaclass:
                return metaclass.qname() == "enum.EnumMeta"
            return False
        if not has_known_bases(owner):
            return False
    if isinstance(owner, objects.Super):
        # Verify if we are dealing with an invalid Super object.
        # If it is invalid, then there's no point in checking that
        # it has the required attribute. Also, don't fail if the
        # MRO is invalid.
        try:
            owner.super_mro()
        except (exceptions.MroError, exceptions.SuperError):
            return False
        if not all(map(has_known_bases, owner.type.mro())):
            return False
    if isinstance(owner, astroid.Module):
        try:
            owner.getattr("__getattr__")
            return False
        except astroid.NotFoundError:
            pass
    if node.attrname.startswith("_" + owner_name):
        # Test if an attribute has been mangled ('private' attribute)
        unmangled_name = node.attrname.split("_" + owner_name)[-1]
        try:
            if owner.getattr(unmangled_name, context=None) is not None:
                return False
        except astroid.NotFoundError:
            return True
    return True
def _emit_no_member ( node , owner , owner_name , ignored_mixins = True , ignored_none = True ) : # pylint: disable=too-many-return-statements if node_ignores_exception ( node , AttributeError ) : return False if ignored_none and isinstance ( owner , astroid . Const ) and owner . value is None : return False if is_super ( owner ) or getattr ( owner , "type" , None ) == "metaclass" : return False if ignored_mixins and owner_name [ - 5 : ] . lower ( ) == "mixin" : return False if isinstance ( owner , astroid . FunctionDef ) and owner . decorators : return False if isinstance ( owner , ( astroid . Instance , astroid . ClassDef ) ) : if owner . has_dynamic_getattr ( ) : # Issue #2565: Don't ignore enums, as they have a `__getattr__` but it's not # invoked at this point. try : metaclass = owner . metaclass ( ) except exceptions . MroError : return False if metaclass : return metaclass . qname ( ) == "enum.EnumMeta" return False if not has_known_bases ( owner ) : return False if isinstance ( owner , objects . Super ) : # Verify if we are dealing with an invalid Super object. # If it is invalid, then there's no point in checking that # it has the required attribute. Also, don't fail if the # MRO is invalid. try : owner . super_mro ( ) except ( exceptions . MroError , exceptions . SuperError ) : return False if not all ( map ( has_known_bases , owner . type . mro ( ) ) ) : return False if isinstance ( owner , astroid . Module ) : try : owner . getattr ( "__getattr__" ) return False except astroid . NotFoundError : pass if node . attrname . startswith ( "_" + owner_name ) : # Test if an attribute has been mangled ('private' attribute) unmangled_name = node . attrname . split ( "_" + owner_name ) [ - 1 ] try : if owner . getattr ( unmangled_name , context = None ) is not None : return False except astroid . NotFoundError : return True return True
Try to see if no-member should be emitted for the given owner.

    The following cases are ignored:

        * the owner is a function and it has decorators.
        * the owner is an instance and it has __getattr__, __getattribute__ implemented
        * the module is explicitly ignored from no-member checks
        * the owner is a class and the name can be found in its metaclass.
        * The access node is protected by an except handler, which handles
          AttributeError, Exception or bare except.
Try to see if no - member should be emitted for the given owner .