void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement element = descriptor.getPsiElement(); List<PyExpression> problemElements = ContainerUtil.map(myProblemElements, SmartPsiElementPointer::getElement); if (problemElements.contains(null)) return; PyArgumentList argumentList = PsiTreeUtil.getParentOfType(element, PyArgumentList.class); if (argumentList == null) return; StringBuilder newArgumentList = new StringBuilder("foo("); PyExpression[] arguments = argumentList.getArguments(); List<String> newArgs = new ArrayList<>(); for (int i = 0; i != arguments.length; ++i) { if (!problemElements.contains(arguments[i])) { newArgs.add(arguments[i].getText()); } } newArgumentList.append(StringUtil.join(newArgs, ", ")).append(")"); PyExpression expression = PyElementGenerator.getInstance(project).createFromText( LanguageLevel.forElement(argumentList), PyExpressionStatement.class, newArgumentList.toString()).getExpression(); if (expression instanceof PyCallExpression) { argumentList.replace(((PyCallExpression)expression).getArgumentList()); } }