mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 20:39:40 +07:00
PY-45143 Fix false positive redundant parentheses in yield from
GitOrigin-RevId: 0a0f2000feec265030ff16029ddda0ab72b923b9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8b571a88b3
commit
46919b1830
@@ -117,8 +117,8 @@ public final class PyRedundantParenthesesInspection extends PyInspection {
|
||||
registerProblem(node, PyPsiBundle.message("QFIX.redundant.parentheses"), new RedundantParenthesesQuickFix());
|
||||
}
|
||||
else if (parent instanceof PyReturnStatement || parent instanceof PyYieldExpression) {
|
||||
if (!isTupleWithUnpacking(expression) && !oneElementTuple(expression) ||
|
||||
languageLevel.isAtLeast(LanguageLevel.PYTHON38) && !isYieldFrom(parent)) {
|
||||
if (!(isTupleWithUnpacking(expression) && languageLevel.isOlderThan(LanguageLevel.PYTHON38)) && !oneElementTuple(expression) &&
|
||||
!isYieldFrom(parent)) {
|
||||
registerProblem(node, PyPsiBundle.message("QFIX.redundant.parentheses"), new RedundantParenthesesQuickFix());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
def f():
|
||||
yield from ('a', 'b', 'c', 'd')
|
||||
|
||||
def f():
|
||||
yield from (('a', 'b'), ('c', 'd'))
|
||||
@@ -117,9 +117,12 @@ public class PyRedundantParenthesesInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
// PY-34262
|
||||
public void testReturnOneElementTuple() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON27, () -> {
|
||||
doTestByText("def foo():\n" +
|
||||
" return (1, )");
|
||||
});
|
||||
doTestByText("def foo():\n" +
|
||||
" return (1, )");
|
||||
}
|
||||
|
||||
// PY-45143
|
||||
public void testNoInspectionWithYieldFrom() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user