void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); final PyAssignmentStatement assignmentStatement = as(descriptor.getPsiElement(), PyAssignmentStatement.class); if (assignmentStatement == null) return; final PyExpression assignedValue = assignmentStatement.getAssignedValue(); if (assignedValue == null) return; List<PyExpressionStatement> appendCalls = PyListCreationInspection.collectSubsequentListAppendCalls(assignmentStatement); final List<PyExpression> items = buildLiteralItems(assignedValue, appendCalls); appendCalls.forEach(PyExpressionStatement::delete); final String text = "[" + StringUtil.join(items, PyExpression::getText, ", ") + "]"; assignedValue.replace(elementGenerator.createExpressionFromText(LanguageLevel.forElement(assignedValue), text)); }