From 67f5a8462b6378e443246a971b8bdce316db1520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylvain=20Th=C3=A9nault?= Date: Sat, 23 Sep 2006 14:00:03 +0200 Subject: [PATCH] fix false positives with py >= 2.5 --- checkers/base.py | 3 ++- checkers/newstyle.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/checkers/base.py b/checkers/base.py index 4a7c70e1b..5559ca7db 100644 --- a/checkers/base.py +++ b/checkers/base.py @@ -327,7 +327,8 @@ functions, methods self.add_message('W0105', node=node) return # ignore if this is a function call (can't predicate side effects) - if not isinstance(node.expr, astng.CallFunc): + # or a yield (which are wrapped by a discard node in py >= 2.5) + if not isinstance(node.expr, (astng.CallFunc, astng.Yield)): self.add_message('W0104', node=node) def visit_function(self, node): diff --git a/checkers/newstyle.py b/checkers/newstyle.py index 7383a5698..9832a72cc 100644 --- a/checkers/newstyle.py +++ b/checkers/newstyle.py @@ -16,7 +16,7 @@ """check for new / old style related problems """ -__revision__ = "$Id: newstyle.py,v 1.8 2006-03-05 14:39:38 syt Exp $" +import sys from logilab import astng @@ -32,8 +32,8 @@ MSGS = { 'Used when another argument than the current class is given as \ first argument of the super builtin.'), 'E1010': ('Raising a new style class', - 'Used when a new style class is raised since it\'s not yet \ - possible.'), + 'Used when a new style class is raised since it\'s not \ + possible with python < 2.5.'), 'W1001': ('Use of "property" on an old style class', 'Used when PyLint detect the use of the builtin "property" \ @@ -96,7 +96,7 @@ class NewStyleConflictChecker(BaseChecker): pass else: if isinstance(value, astng.Class): - if value.newstyle: + if value.newstyle and sys.version_info < (2, 5): self.add_message('E1010', node=node) elif not inherit_from_std_ex(value): self.add_message('W1010', node=node)