diff --git a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyCollectionTypeUtil.kt b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyCollectionTypeUtil.kt index 31257be2757a..1d2fe3e87acd 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyCollectionTypeUtil.kt +++ b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyCollectionTypeUtil.kt @@ -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] diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 512e2e2cb0ce..e7dd1ac2a379 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -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]", """