diff --git a/python/src/com/jetbrains/python/formatter/PyBlock.java b/python/src/com/jetbrains/python/formatter/PyBlock.java index c40796b32336..584ba85dad95 100644 --- a/python/src/com/jetbrains/python/formatter/PyBlock.java +++ b/python/src/com/jetbrains/python/formatter/PyBlock.java @@ -352,7 +352,7 @@ public class PyBlock implements ASTBlock { if (type2 == PyElementTypes.STATEMENT_LIST) { return Spacing.createSpacing(1, Integer.MAX_VALUE, 0, true, 0); } - if (parentType == PyElementTypes.KEY_VALUE_EXPRESSION) { + if (parentType == PyElementTypes.KEY_VALUE_EXPRESSION || parentType == PyElementTypes.LAMBDA_EXPRESSION) { return getSpacingForOption(getPySettings().SPACE_AFTER_PY_COLON); } } @@ -387,7 +387,7 @@ public class PyBlock implements ASTBlock { if (type2 == PyElementTypes.ARGUMENT_LIST) { return getSpacingForOption(mySettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES); } - if (type2 == PyElementTypes.PARAMETER_LIST) { + if (type2 == PyElementTypes.PARAMETER_LIST && type1 != PyTokenTypes.LAMBDA_KEYWORD) { return getSpacingForOption(mySettings.SPACE_BEFORE_METHOD_PARENTHESES); } diff --git a/python/testData/formatter/lambdaColon.py b/python/testData/formatter/lambdaColon.py new file mode 100644 index 000000000000..b46986036c6b --- /dev/null +++ b/python/testData/formatter/lambdaColon.py @@ -0,0 +1 @@ +lambda o:o.fullName() diff --git a/python/testData/formatter/lambdaColon_after.py b/python/testData/formatter/lambdaColon_after.py new file mode 100644 index 000000000000..497e4dc07ffa --- /dev/null +++ b/python/testData/formatter/lambdaColon_after.py @@ -0,0 +1 @@ +lambda o: o.fullName() diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index 814518e7d63b..e4e5b7ae80a7 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -135,6 +135,10 @@ public class PyFormatterTest extends PyLightFixtureTestCase { CodeStyleSettingsManager.getInstance().getSettings(myFixture.getProject()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; doTest(); } + + public void testLambdaColon() { + doTest(); + } public void testPsiFormatting() { // IDEA-69724 String initial =