PositionalArgumentsAnalysisResults (@NotNull List<PyExpression> arguments) { final List<PyExpression> variadicArguments = new ArrayList<>(); final List<PyExpression> allPositionalArguments = new ArrayList<>(); final List<PyExpression> componentsOfVariadicPositionalArguments = new ArrayList<>(); boolean seenVariadicPositionalArgument = false; boolean seenVariadicKeywordArgument = false; boolean seenKeywordArgument = false; for (PyExpression argument : arguments) { if (argument instanceof PyStarArgument) { if (((PyStarArgument)argument).isKeyword()) { seenVariadicKeywordArgument = true; } else { seenVariadicPositionalArgument = true; final PsiElement expr = PyPsiUtils.flattenParens(PsiTreeUtil.getChildOfType(argument, PyExpression.class)); if (expr instanceof PySequenceExpression sequenceExpr) { final List<PyExpression> elements = Arrays.asList(sequenceExpr.getElements()); allPositionalArguments.addAll(elements); componentsOfVariadicPositionalArguments.addAll(elements); } else { variadicArguments.add(argument); } } } else if (argument instanceof PyKeywordArgument) { seenKeywordArgument = true; } else { if (seenKeywordArgument || seenVariadicKeywordArgument || seenVariadicPositionalArgument && LanguageLevel.forElement(argument).isOlderThan(LanguageLevel.PYTHON35)) { continue; } allPositionalArguments.add(argument); } } return new PositionalArgumentsAnalysisResults(allPositionalArguments, componentsOfVariadicPositionalArguments, variadicArguments); }