diff --git a/src/pep8ext_naming.py b/src/pep8ext_naming.py index 707ed23..edfdaa5 100644 --- a/src/pep8ext_naming.py +++ b/src/pep8ext_naming.py @@ -180,9 +180,10 @@ def tag_class_functions(self, cls_node): if isinstance(meth, ast.Name): late_decoration[meth.id] = self.decorator_to_type[func_name] + cls_bases = [b for b in cls_node.bases if isinstance(b, ast.Name)] # If this class inherits from `type`, it's a metaclass, and we'll # consider all of it's methods to be classmethods. - ismetaclass = any(name for name in cls_node.bases if name.id == 'type') + ismetaclass = any(name for name in cls_bases if name.id == 'type') # iterate over all functions and tag them for node in iter_child_nodes(cls_node): diff --git a/testsuite/N804.py b/testsuite/N804.py index d488282..9d9a0b4 100644 --- a/testsuite/N804.py +++ b/testsuite/N804.py @@ -27,3 +27,10 @@ def __new__(self, name, bases, attrs): class MetaMethod(type): def test(cls): pass +#: Okay +class NotMeta(object): + otherclass = Foo +class AttributeParent(NotMeta.otherclass): + pass +class CallParent(type('_tmp', (), {})): + pass