mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-52760 Type checker fails at tuple unpacking into a dictionary
GitOrigin-RevId: dbf1181099501764ac9b0d42813b37b48882379c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2d3d4c8470
commit
cdfef53944
@@ -11,7 +11,6 @@ import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil
|
||||
import com.jetbrains.python.psi.*
|
||||
import com.jetbrains.python.psi.impl.PyBuiltinCache
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext
|
||||
import com.jetbrains.python.pyi.PyiUtil
|
||||
|
||||
object PyCollectionTypeUtil {
|
||||
|
||||
@@ -360,9 +359,8 @@ object PyCollectionTypeUtil {
|
||||
}
|
||||
|
||||
var rightValue = assignment.assignedValue
|
||||
if (tupleParent != null && rightValue is PyTupleExpression) {
|
||||
val rightTuple = rightValue as PyTupleExpression?
|
||||
val rightElements = rightTuple!!.elements
|
||||
if (tupleParent != null) {
|
||||
val rightElements = PyUtil.flattenedParensAndLists(rightValue)
|
||||
val indexInAssignment = tupleParent.elements.indexOf(node)
|
||||
if (indexInAssignment < rightElements.size) {
|
||||
rightValue = rightElements[indexInAssignment]
|
||||
|
||||
@@ -1125,6 +1125,27 @@ public class PyTypeTest extends PyTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
// PY-52760
|
||||
public void testTupleLiteralDestructuringAssignmentToDict() {
|
||||
doTest(
|
||||
"Dict[str, int]",
|
||||
"""
|
||||
expr = {}
|
||||
expr["a"], _ = (1, 2)
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
public void testListLiteralDestructuringAssignmentToDict() {
|
||||
doTest(
|
||||
"Dict[str, int]",
|
||||
"""
|
||||
expr = {}
|
||||
expr["a"], _ = [1, 2]
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
public void testConstructorUnification() {
|
||||
doTest("C[int]",
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user