Skip to content

Commit

Permalink
Merge pull request #55 from PyCQA/bug/53
Browse files Browse the repository at this point in the history
Only check ast.Name for their id in metaclass check
  • Loading branch information
sigmavirus24 authored May 6, 2018
2 parents fbb261b + 821c00b commit 311f330
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pep8ext_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions testsuite/N804.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 311f330

Please sign in to comment.