void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); final Map<String, String> statementsMap = Maps.newLinkedHashMap(); final PyAssignmentStatement myStatement = as(descriptor.getPsiElement(), PyAssignmentStatement.class); if (myStatement == null) return; final PyExpression assignedValue = myStatement.getAssignedValue(); if (assignedValue instanceof PyDictLiteralExpression) { for (PsiElement expression : assignedValue.getChildren()) { if (expression instanceof PyKeyValueExpression kvExpr) { final PyExpression value = kvExpr.getValue(); if (value != null) { statementsMap.put(kvExpr.getKey().getText(), value.getText()); } } else if (expression instanceof PyDoubleStarExpression) { statementsMap.put(expression.getText(), null); } } PyStatement statement = PsiTreeUtil.getNextSiblingOfType(myStatement, PyStatement.class); while (statement instanceof PyAssignmentStatement assignmentStatement) { final PyExpression target = myStatement.getTargets()[0]; final String targetName = target.getName(); if (targetName != null) { final List<Pair<PyExpression, PyExpression>> targetsToValues = PyDictCreationInspection.getDictTargets(target, targetName, assignmentStatement); final PyStatement nextStatement = PsiTreeUtil.getNextSiblingOfType(statement, PyStatement.class); if (targetsToValues == null || targetsToValues.isEmpty()) break; for (Pair<PyExpression, PyExpression> targetToValue : targetsToValues) { final PySubscriptionExpression subscription = (PySubscriptionExpression)targetToValue.first; final PyExpression indexExpression = subscription.getIndexExpression(); assert indexExpression != null; final String indexText; if (indexExpression instanceof PyTupleExpression) { indexText = "(" + indexExpression.getText() + ")"; } else { indexText = indexExpression.getText(); } final String valueText; if (targetToValue.second instanceof PyTupleExpression) { valueText = "(" + targetToValue.second.getText() + ")"; } else { valueText = targetToValue.second.getText(); } statementsMap.put(indexText, valueText); statement.delete(); } statement = nextStatement; } } List<String> statements = new ArrayList<>(); for (Map.Entry<String, String> entry : statementsMap.entrySet()) { if (entry.getValue() != null) { statements.add(entry.getKey() + ": " + entry.getValue()); } else { statements.add(entry.getKey()); } } final PyExpression expression = elementGenerator.createExpressionFromText(LanguageLevel.forElement(myStatement), "{" + StringUtil.join(statements, ", ") + "}"); assignedValue.replace(expression); } }