diff --git a/python/src/com/jetbrains/python/codeInsight/PySubstitutionChunkReference.java b/python/src/com/jetbrains/python/codeInsight/PySubstitutionChunkReference.java index e66921b4ad00..23b54b8eaa3e 100644 --- a/python/src/com/jetbrains/python/codeInsight/PySubstitutionChunkReference.java +++ b/python/src/com/jetbrains/python/codeInsight/PySubstitutionChunkReference.java @@ -395,8 +395,8 @@ public class PySubstitutionChunkReference extends PsiReferenceBase resolvedRef = getElementFromDictLiteral((PyDictLiteralExpression)containedExpr, key, resolveContext); + if (PyUtil.instanceOf(containedExpr, PyDictLiteralExpression.class, PyCallExpression.class)) { + final Ref resolvedRef = getElementFromDictLiteral(containedExpr, key, resolveContext); return resolvedRef != null ? resolvedRef.get() : containedExpr; } else if (PyUtil.instanceOf(containedExpr, PyLiteralExpression.class, PySetLiteralExpression.class, @@ -457,7 +457,6 @@ public class PySubstitutionChunkReference extends PsiReferenceBase'{first}, {second}, {third}'.format(**dict(first='a', second='b')) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyResolveTest.java b/python/testSrc/com/jetbrains/python/PyResolveTest.java index e52d361b4413..0cbf3392e7fd 100644 --- a/python/testSrc/com/jetbrains/python/PyResolveTest.java +++ b/python/testSrc/com/jetbrains/python/PyResolveTest.java @@ -719,7 +719,7 @@ public class PyResolveTest extends PyResolveTestCase { //PY-2748 public void testFormatStringPackedDictCall() { PsiElement target = resolve(); - assertInstanceOf(target, PyStarArgument.class); + assertInstanceOf(target, PyKeywordArgument.class); } //PY-2748 diff --git a/python/testSrc/com/jetbrains/python/inspections/PyStringFormatInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyStringFormatInspectionTest.java index 56805529d3bc..b14a3df62414 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyStringFormatInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyStringFormatInspectionTest.java @@ -208,6 +208,11 @@ public class PyStringFormatInspectionTest extends PyTestCase { public void testPackedStringTooFewArguments() { doTest(); } + + // PY-21156 + public void testPackedDictCallUnusedMappingKey() { + doTest(); + } private void doTest() { myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");