PY-26877 Support adding trailing commas to multiline collections, argument and parameter lists

Merge-request: IJ-MR-153633
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: b304977e30eb4b378d858fcc5300846dc5965445
This commit is contained in:
Daniil Kalinin
2025-02-14 08:46:05 +00:00
committed by intellij-monorepo-bot
parent 202a78ddeb
commit 97ba49d547
22 changed files with 713 additions and 3 deletions

View File

@@ -20,7 +20,6 @@ formatter.align.when.multiline=Align when multiline
formatter.collections.and.comprehensions=Collections and Comprehensions
formatter.from.import.statements="From" Import Statements
formatter.from.import.statements.force.parentheses.if.multiline=Force parentheses if multiline
formatter.from.import.statements.force.comma.if.multline=Force trailing comma if multiline
formatter.dictionary.literals=Dictionary literals
formatter.hang.closing.brackets=Hang closing brackets
formatter.list.literals=List literals
@@ -49,3 +48,5 @@ formatter.panel.use.continuation.indent.for.arguments=Method call arguments
formatter.panel.use.continuation.indent.for.collection.literals=Collections and comprehensions
configurable.PyLanguageCodeStyleSettingsProvider.display.name=Python
formatter.force.trailing.comma.if.multiline=Force trailing comma if multiline

View File

@@ -102,6 +102,17 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle
"METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE",
"METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE",
"ALIGN_MULTILINE_PARAMETERS_IN_CALLS");
consumer.showCustomOption(PyCodeStyleSettings.class,
"USE_TRAILING_COMMA_IN_ARGUMENTS_LIST",
PySyntaxBundle.message("formatter.force.trailing.comma.if.multiline"),
ApplicationBundle.message("wrapping.method.arguments"));
consumer.showCustomOption(PyCodeStyleSettings.class,
"USE_TRAILING_COMMA_IN_PARAMETER_LIST",
PySyntaxBundle.message("formatter.force.trailing.comma.if.multiline"),
ApplicationBundle.message("wrapping.method.parameters"));
consumer.showCustomOption(PyCodeStyleSettings.class, "NEW_LINE_AFTER_COLON",
PySyntaxBundle.message("formatter.single.clause.statements"),
PySyntaxBundle.message("formatter.force.new.line.after.colon"));
@@ -111,6 +122,10 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle
consumer.showCustomOption(PyCodeStyleSettings.class, "ALIGN_COLLECTIONS_AND_COMPREHENSIONS",
PySyntaxBundle.message("formatter.align.when.multiline"),
PySyntaxBundle.message("formatter.collections.and.comprehensions"));
consumer.showCustomOption(PyCodeStyleSettings.class,
"USE_TRAILING_COMMA_IN_COLLECTIONS",
PySyntaxBundle.message("formatter.force.trailing.comma.if.multiline"),
PySyntaxBundle.message("formatter.collections.and.comprehensions"));
consumer.showCustomOption(PyCodeStyleSettings.class, "FROM_IMPORT_WRAPPING",
PySyntaxBundle.message("formatter.from.import.statements"), null, getInstance().WRAP_OPTIONS, WRAP_VALUES);
@@ -127,7 +142,7 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle
PySyntaxBundle.message("formatter.from.import.statements.force.parentheses.if.multiline"),
PySyntaxBundle.message("formatter.from.import.statements"));
consumer.showCustomOption(PyCodeStyleSettings.class, "FROM_IMPORT_TRAILING_COMMA_IF_MULTILINE",
PySyntaxBundle.message("formatter.from.import.statements.force.comma.if.multline"),
PySyntaxBundle.message("formatter.force.trailing.comma.if.multiline"),
PySyntaxBundle.message("formatter.from.import.statements"));
consumer.showCustomOption(PyCodeStyleSettings.class, "LIST_WRAPPING",