void (@NotNull PyFromImportStatement node) { if (myHelper.isElementFullyInRange(node)) { // If non-parenthesized "from" import ends with one or more of trailing commas, the array returned by getImportElements() // contains empty import elements at the end final List<PyImportElement> importedNames = ContainerUtil.filter(node.getImportElements(), elem -> elem.getTextLength() != 0); if (importedNames.size() > 1) { final PyCodeStyleSettings pySettings = myHelper.getSettings().getRootSettings().getCustomSettings(PyCodeStyleSettings.class); final boolean forcedParens = pySettings.FROM_IMPORT_PARENTHESES_FORCE_IF_MULTILINE && PostFormatProcessorHelper.isMultiline(node); final boolean forcedComma = pySettings.FROM_IMPORT_TRAILING_COMMA_IF_MULTILINE && PostFormatProcessorHelper.isMultiline(node); final PyImportElement lastImportedName = importedNames.get(importedNames.size() - 1); final PsiElement afterLastName = PyPsiUtils.getNextNonCommentSibling(lastImportedName, true); final PsiElement openingParen = node.getLeftParen(); final boolean missingComma = afterLastName == null || afterLastName.getNode().getElementType() != PyTokenTypes.COMMA; // Trailing comma is allowed only in "from" imports wrapped in parentheses if (forcedParens && openingParen == null || forcedComma && missingComma && openingParen != null) { myImportStatements.add(node); } } } }