mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix calculating arguments for __setitem__ (PY-27949)
This commit is contained in:
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package com.jetbrains.python.psi;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,6 +37,12 @@ public interface PySubscriptionExpression extends PyQualifiedExpression, PyCallS
|
||||
@NotNull
|
||||
@Override
|
||||
default List<PyExpression> getArguments(@Nullable PyCallable resolvedCallee) {
|
||||
if (AccessDirection.of(this) == AccessDirection.WRITE) {
|
||||
final PsiElement parent = getParent();
|
||||
if (parent instanceof PyAssignmentStatement) {
|
||||
return Arrays.asList(getIndexExpression(), ((PyAssignmentStatement)parent).getAssignedValue());
|
||||
}
|
||||
}
|
||||
return Collections.singletonList(getIndexExpression());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from typing import Dict
|
||||
|
||||
data = {} # type: Dict[int, str]
|
||||
data[<weak_warning descr="Expected type 'int' (matched generic type '_KT'), got 'str' instead">'test'</weak_warning>] = <weak_warning descr="Expected type 'str' (matched generic type '_VT'), got 'int' instead">12</weak_warning>
|
||||
data[12] = 'test'
|
||||
@@ -530,4 +530,9 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
public void testOverloadedFunctionAssignedToTargetInStub() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
// PY-27949
|
||||
public void testAssigningToDictEntry() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user