void (@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); if (!(element instanceof PyTargetExpression targetExpression)) return; final PyClass containingClass = targetExpression.getContainingClass(); final PyAssignmentStatement assignment = PsiTreeUtil.getParentOfType(element, PyAssignmentStatement.class); if (containingClass == null || assignment == null) return; if (!FileModificationService.getInstance().preparePsiElementForWrite(containingClass)) return; WriteAction.run(() -> { AddFieldQuickFix.addFieldToInit(project, containingClass, ((PyTargetExpression)element).getName(), x -> assignment); removeDefinition(assignment); }); }