mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-21156 Resolve to keyword argument for dict call
This commit is contained in:
@@ -395,8 +395,8 @@ public class PySubstitutionChunkReference extends PsiReferenceBase<PyStringLiter
|
||||
private PyExpression resolveKeywordPercent(@NotNull PyExpression expression, @NotNull String key) {
|
||||
final PyExpression containedExpr = PyPsiUtils.flattenParens(expression);
|
||||
final PyResolveContext resolveContext = PyResolveContext.noImplicits().withTypeEvalContext(myTypeEvalContext);
|
||||
if (containedExpr instanceof PyDictLiteralExpression) {
|
||||
final Ref<PyExpression> resolvedRef = getElementFromDictLiteral((PyDictLiteralExpression)containedExpr, key, resolveContext);
|
||||
if (PyUtil.instanceOf(containedExpr, PyDictLiteralExpression.class, PyCallExpression.class)) {
|
||||
final Ref<PyExpression> 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<PyStringLiter
|
||||
return containedExpression;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static PyArgumentList getArgumentList(final PsiElement original) {
|
||||
final PsiElement pyReferenceExpression = PsiTreeUtil.getParentOfType(original, PyReferenceExpression.class);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<warning descr="Mapping key \"third\" is unused">'{first}, {second}, {third}'</warning>.format(**dict(first='a', second='b'))
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user