String (@NotNull PyExpression argumentValue, @NotNull PyFunction function, @NotNull Set<String> usedParameterNames, @NotNull TypeEvalContext context) { final Collection<String> suggestions = new LinkedHashSet<>(); final PyCallExpression callExpr = as(argumentValue, PyCallExpression.class); final PyElement referenceElem = as(callExpr != null ? callExpr.getCallee() : argumentValue, PyReferenceExpression.class); if (referenceElem != null) { suggestions.addAll(NameSuggesterUtil.generateNames(referenceElem.getText())); } if (suggestions.isEmpty()) { PyType type = context.getType(argumentValue); if (type instanceof PyUnionType) { type = ContainerUtil.find(((PyUnionType)type).getMembers(), Conditions.instanceOf(PyClassType.class)); } final String typeName = type != null && type.getName() != null ? type.getName() : "object"; suggestions.addAll(NameSuggesterUtil.generateNamesByType(typeName)); } final String shortestName = Collections.min(suggestions, Comparator.comparingInt(String::length)); String result = shortestName; int counter = 1; while (!PyRefactoringUtil.isValidNewName(result, function.getStatementList()) || usedParameterNames.contains(result)) { result = shortestName + counter; counter++; } return result; }