diff --git a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java index 4b71d6abec25..6187b5dc46b4 100644 --- a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java +++ b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java @@ -113,6 +113,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C .withinPairInside(LPAR, RPAR, ARGUMENT_LIST).spaceIf(commonSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES) .withinPairInside(LPAR, RPAR, PARAMETER_LIST).spaceIf(commonSettings.SPACE_WITHIN_METHOD_PARENTHESES) .withinPairInside(LPAR, RPAR, FROM_IMPORT_STATEMENT).spaces(0) + .withinPairInside(LPAR, RPAR, GENERATOR_EXPRESSION).spaces(0) .before(LBRACKET).spaceIf(pySettings.SPACE_BEFORE_LBRACKET) .withinPair(LBRACE, RBRACE).spaceIf(pySettings.SPACE_WITHIN_BRACES) diff --git a/python/testData/formatter/parenthesisAroundGeneratorExpression.py b/python/testData/formatter/parenthesisAroundGeneratorExpression.py new file mode 100644 index 000000000000..951a773bca4c --- /dev/null +++ b/python/testData/formatter/parenthesisAroundGeneratorExpression.py @@ -0,0 +1 @@ +gen = ( for c in 'abrakadabra' ) \ No newline at end of file diff --git a/python/testData/formatter/parenthesisAroundGeneratorExpression_after.py b/python/testData/formatter/parenthesisAroundGeneratorExpression_after.py new file mode 100644 index 000000000000..7b94eb9d1c4e --- /dev/null +++ b/python/testData/formatter/parenthesisAroundGeneratorExpression_after.py @@ -0,0 +1 @@ +gen = (for c in 'abrakadabra') \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index 35a97e03efae..4c6e3fd22e7a 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -404,6 +404,10 @@ public class PyFormatterTest extends PyTestCase { doTest(); } + public void testParenthesisAroundGeneratorExpression() { + doTest(); + } + private void doTest() { doTest(false); }