diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java index 753d6db758b8..16998e06b103 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java @@ -304,10 +304,8 @@ public class ConvertFormatOperatorToMethodIntention extends BaseIntentionAction } } } - else if (rhsType instanceof PyCollectionType) { - if ("dict".equals(rhsType.getName())) { - target.append("(**").append(paramText).append(")"); - } + else if (rhsType instanceof PyCollectionType && "dict".equals(rhsType.getName())) { + target.append("(**").append(paramText).append(")"); } else target.append("(").append(paramText).append(")"); // tuple is ok as is // Correctly handle multiline implicitly concatenated string literals (PY-9176) diff --git a/python/testData/intentions/PyConvertFormatOperatorToMethodIntentionTest/set.py b/python/testData/intentions/PyConvertFormatOperatorToMethodIntentionTest/set.py new file mode 100644 index 000000000000..ee39c0e392d3 --- /dev/null +++ b/python/testData/intentions/PyConvertFormatOperatorToMethodIntentionTest/set.py @@ -0,0 +1 @@ +print('%s' % {1, 2}) \ No newline at end of file diff --git a/python/testData/intentions/PyConvertFormatOperatorToMethodIntentionTest/set_after.py b/python/testData/intentions/PyConvertFormatOperatorToMethodIntentionTest/set_after.py new file mode 100644 index 000000000000..6d879b230d07 --- /dev/null +++ b/python/testData/intentions/PyConvertFormatOperatorToMethodIntentionTest/set_after.py @@ -0,0 +1 @@ +print('{}'.format({1, 2})) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java b/python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java index a8a09adb9f38..e31ec3ad703e 100644 --- a/python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java +++ b/python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java @@ -82,5 +82,10 @@ public class PyConvertFormatOperatorToMethodIntentionTest extends PyIntentionTes // PY-20803 public void testStarWidthPrecision() { doNegativeTest(PyBundle.message("INTN.replace.with.method")); - } + } + + // PY-20876 + public void testSet() { + doTest(PyBundle.message("INTN.replace.with.method"), LanguageLevel.PYTHON26); + } } \ No newline at end of file