diff options
| author | cpopa <devnull@localhost> | 2014-08-18 10:55:46 +0300 |
|---|---|---|
| committer | cpopa <devnull@localhost> | 2014-08-18 10:55:46 +0300 |
| commit | 19ea91dd27f970d9bd30cf9551b2770ab0fbb16b (patch) | |
| tree | ee126c1a40ac04ab812ef649fab2167a8d51c164 | |
| parent | 98d800bdab4f9d7209b0466ee62036638c511abd (diff) | |
| download | pylint-19ea91dd27f970d9bd30cf9551b2770ab0fbb16b.tar.gz | |
Revert change from 3b748b4: emit old-style-classes only for classes without bases and without explicitly defined metaclasses.
| -rw-r--r-- | checkers/newstyle.py | 7 | ||||
| -rw-r--r-- | test/functional/old_style_class_py27.py | 12 | ||||
| -rw-r--r-- | test/messages/func_w0231.txt | 1 |
3 files changed, 10 insertions, 10 deletions
diff --git a/checkers/newstyle.py b/checkers/newstyle.py index 532f3f1..cf50229 100644 --- a/checkers/newstyle.py +++ b/checkers/newstyle.py @@ -79,9 +79,10 @@ class NewStyleConflictChecker(BaseChecker): """ if '__slots__' in node and not node.newstyle: self.add_message('slots-on-old-class', node=node) - # If the class node is not marked as newstyle and it has no explicitly - # defined metaclass, then it's an old style class. - if not node.newstyle and node.type == 'class' and not node.metaclass(): + # The node type could be class, exception, metaclass, or + # interface. Presumably, the non-class-type nodes would always + # have an explicit base class anyway. + if not node.bases and node.type == 'class' and not node.metaclass(): self.add_message('old-style-class', node=node) @check_messages('property-on-old-class') diff --git a/test/functional/old_style_class_py27.py b/test/functional/old_style_class_py27.py index 4073c73..2c3c126 100644 --- a/test/functional/old_style_class_py27.py +++ b/test/functional/old_style_class_py27.py @@ -4,14 +4,14 @@ class Old: # [old-style-class]
""" old style class """
-class Child(Old): # [old-style-class]
- """ still an old style class """
+class Child(Old):
+ """ Old style class, but don't emit for it. """
+
+class NotOldStyle2:
+ """ Because I have a metaclass at class level. """
+ __metaclass__ = type
__metaclass__ = type
class NotOldStyle:
""" Because I have a metaclass at global level. """
-
-class NotOldStyle2:
- """ Because I have a metaclass at class level. """
- __metaclass__ = type
diff --git a/test/messages/func_w0231.txt b/test/messages/func_w0231.txt index 2f97fba..8cbf0b7 100644 --- a/test/messages/func_w0231.txt +++ b/test/messages/func_w0231.txt @@ -1,7 +1,6 @@ C: 7:AAAA: Old-style class defined. C: 13:BBBB: Old-style class defined. C: 19:CCCC: Old-style class defined. -C: 23:ZZZZ: Old-style class defined. W: 19:CCCC: Class has no __init__ method W: 26:ZZZZ.__init__: __init__ method from base class 'BBBB' is not called W: 59:AssignedInit.__init__: __init__ method from base class 'NewStyleC' is not called |
