diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertTripleQuotedStringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertTripleQuotedStringIntention.java index 5fc125748e1c..a84d19f71dd7 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertTripleQuotedStringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertTripleQuotedStringIntention.java @@ -94,7 +94,8 @@ public class PyConvertTripleQuotedStringIntention extends BaseIntentionAction { PyExpressionStatement e = elementGenerator.createFromText(LanguageLevel.forElement(string), PyExpressionStatement.class, result.toString()); PyExpression expression = e.getExpression(); - if (parent instanceof PyTupleExpression && expression instanceof PyParenthesizedExpression) + if ((parent instanceof PyParenthesizedExpression || parent instanceof PyTupleExpression) + && expression instanceof PyParenthesizedExpression) expression = ((PyParenthesizedExpression)expression).getContainedExpression(); if (expression != null) string.replace(expression); diff --git a/python/testData/intentions/afterConvertTripleQuotedStringInParenthesized.py b/python/testData/intentions/afterConvertTripleQuotedStringInParenthesized.py new file mode 100644 index 000000000000..794289cbc830 --- /dev/null +++ b/python/testData/intentions/afterConvertTripleQuotedStringInParenthesized.py @@ -0,0 +1,2 @@ +t = ("string\n" + "some\n") \ No newline at end of file diff --git a/python/testData/intentions/beforeConvertTripleQuotedStringInParenthesized.py b/python/testData/intentions/beforeConvertTripleQuotedStringInParenthesized.py new file mode 100644 index 000000000000..eca7b7334919 --- /dev/null +++ b/python/testData/intentions/beforeConvertTripleQuotedStringInParenthesized.py @@ -0,0 +1,3 @@ +t = ("""string +some +""") \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyIntentionTest.java b/python/testSrc/com/jetbrains/python/PyIntentionTest.java index e9a69cf2cd3e..44c0a6902e69 100644 --- a/python/testSrc/com/jetbrains/python/PyIntentionTest.java +++ b/python/testSrc/com/jetbrains/python/PyIntentionTest.java @@ -253,6 +253,10 @@ public class PyIntentionTest extends PyTestCase { doTest(PyBundle.message("INTN.triple.quoted.string")); } + public void testConvertTripleQuotedStringInParenthesized() { //PY-7883 + doTest(PyBundle.message("INTN.triple.quoted.string")); + } + public void testConvertTripleQuotedUnicodeString() { //PY-7152 doTest(PyBundle.message("INTN.triple.quoted.string")); }