void (@NotNull Project project, @NotNull PsiElement file, @NotNull List<LanguageLevel> versions) { final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile(); final String shortName = getCompatibilityInspectionShortName(); final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project); if (tool != null) { profile.modifyProfile(model -> { final PyCompatibilityInspection inspection = (PyCompatibilityInspection)model.getUnwrappedTool(shortName, file); assert inspection != null; List<String> newVersions = new ArrayList<>(ContainerUtil.map(versions, LanguageLevel::toString)); newVersions.removeAll(inspection.ourVersions); inspection.ourVersions.addAll(newVersions); }); EditInspectionToolsSettingsAction.editToolSettings(project, profile, shortName); } }