From 95df6dc74c92f7241583886d56dbbac0ef795d24 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Tue, 30 Jul 2013 19:31:13 +0400 Subject: [PATCH] fixed PY-10420 False positive in redundant parentheses inspection with yield --- .../python/inspections/PyRedundantParenthesesInspection.java | 2 +- .../inspections/PyRedundantParenthesesInspection/Yield.py | 3 +++ .../inspections/PyRedundantParenthesesInspectionTest.java | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 python/testData/inspections/PyRedundantParenthesesInspection/Yield.py diff --git a/python/src/com/jetbrains/python/inspections/PyRedundantParenthesesInspection.java b/python/src/com/jetbrains/python/inspections/PyRedundantParenthesesInspection.java index 51d66b32bc22..969ef61531ce 100644 --- a/python/src/com/jetbrains/python/inspections/PyRedundantParenthesesInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyRedundantParenthesesInspection.java @@ -57,7 +57,7 @@ public class PyRedundantParenthesesInspection extends PyInspection { PyExpression expression = node.getContainedExpression(); if (node.getText().contains("\n")) return; PyYieldExpression yieldExpression = PsiTreeUtil.getParentOfType(expression, PyYieldExpression.class, false); - if (yieldExpression != null && yieldExpression.isDelegating()) return; + if (yieldExpression != null) return; if (expression instanceof PyReferenceExpression || expression instanceof PyLiteralExpression) { if (myIgnorePercOperator) { PsiElement parent = node.getParent(); diff --git a/python/testData/inspections/PyRedundantParenthesesInspection/Yield.py b/python/testData/inspections/PyRedundantParenthesesInspection/Yield.py new file mode 100644 index 000000000000..bb1e31e104b5 --- /dev/null +++ b/python/testData/inspections/PyRedundantParenthesesInspection/Yield.py @@ -0,0 +1,3 @@ +def foo(): + if (yield 1): + pass \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/inspections/PyRedundantParenthesesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyRedundantParenthesesInspectionTest.java index 7ecc8671b249..7f08fcbd851d 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyRedundantParenthesesInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyRedundantParenthesesInspectionTest.java @@ -60,4 +60,8 @@ public class PyRedundantParenthesesInspectionTest extends PyTestCase { doTest(LanguageLevel.PYTHON33); } + public void testYield() { //PY-10420 + doTest(LanguageLevel.PYTHON27); + } + }