boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof PyFile)) { return false; } final PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); final PyFunction function = PsiTreeUtil.getParentOfType(element, PyFunction.class); if (function != null) { if (LanguageLevel.forElement(function).isPython2() && function.getParameterList().hasPositionalContainer()) { return false; } final Usages usages = findKeywordContainerUsages(function, false); if (usages.hasMoreReferences) return false; final boolean caretInParameterList = PsiTreeUtil.isAncestor(function.getParameterList(), element, true); if (caretInParameterList && ContainerUtil.exists(usages.names.values(), n -> !n.unableToHasDefaultValue)) { return true; } for (Map.Entry<String, DefaultValue> nameAndValue : usages.names.entrySet()) { if (nameAndValue.getValue().unableToHasDefaultValue) continue; final String name = nameAndValue.getKey(); if (ContainerUtil.exists(usages.calls.get(name), c -> PsiTreeUtil.isAncestor(c, element, true)) || ContainerUtil.exists(usages.subscriptions.get(name), s -> PsiTreeUtil.isAncestor(s, element, true))) { return true; } } } return false; }