diff --git a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java index 0ac16716b9c7..28b16126f316 100644 --- a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java +++ b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java @@ -109,7 +109,11 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C } // should be all keywords? - private static final TokenSet SINGLE_SPACE_KEYWORDS = TokenSet.create(IN_KEYWORD, AND_KEYWORD, OR_KEYWORD, IS_KEYWORD); + private static final TokenSet SINGLE_SPACE_KEYWORDS = TokenSet.create(IN_KEYWORD, AND_KEYWORD, OR_KEYWORD, IS_KEYWORD, + IF_KEYWORD, ELIF_KEYWORD, FOR_KEYWORD, RETURN_KEYWORD, RAISE_KEYWORD, + ASSERT_KEYWORD, CLASS_KEYWORD, DEF_KEYWORD, DEL_KEYWORD, + EXEC_KEYWORD, GLOBAL_KEYWORD, IMPORT_KEYWORD, LAMBDA_KEYWORD, + NOT_KEYWORD, WHILE_KEYWORD, YIELD_KEYWORD); private static TokenSet allButLambda() { final PythonLanguage pythonLanguage = PythonLanguage.getInstance(); diff --git a/python/testData/formatter/spaceAfterReturn.py b/python/testData/formatter/spaceAfterReturn.py new file mode 100644 index 000000000000..52eac99007ec --- /dev/null +++ b/python/testData/formatter/spaceAfterReturn.py @@ -0,0 +1,2 @@ +def rc(s): + return s.translate('*****************************************************************TVGHEFCDIJMLKNOPQYSAUBWXRZ[\]^_`tvghefcdijmlknopqysaubwxrz*************************************************************************************************************************************')[::-1] diff --git a/python/testData/formatter/spaceAfterReturn_after.py b/python/testData/formatter/spaceAfterReturn_after.py new file mode 100644 index 000000000000..3abaefbebfec --- /dev/null +++ b/python/testData/formatter/spaceAfterReturn_after.py @@ -0,0 +1,4 @@ +def rc(s): + return s.translate( + '*****************************************************************TVGHEFCDIJMLKNOPQYSAUBWXRZ[\]^_`tvghefcdijmlknopqysaubwxrz*************************************************************************************************************************************')[ + ::-1] diff --git a/python/testData/intentions/demorgan/after1.py b/python/testData/intentions/demorgan/after1.py index ca4312b1267a..a400b76165c8 100644 --- a/python/testData/intentions/demorgan/after1.py +++ b/python/testData/intentions/demorgan/after1.py @@ -1,3 +1,3 @@ # "DeMorgan Law" "true" -if not(not a and not b): +if not (not a and not b): pass \ No newline at end of file diff --git a/python/testData/intentions/demorgan/after2.py b/python/testData/intentions/demorgan/after2.py index 90a925b4f535..902648fbe42f 100644 --- a/python/testData/intentions/demorgan/after2.py +++ b/python/testData/intentions/demorgan/after2.py @@ -1,3 +1,3 @@ # "DeMorgan Law" "true" -if not(a and b): +if not (a and b): pass \ No newline at end of file diff --git a/python/testData/intentions/demorgan/after4.py b/python/testData/intentions/demorgan/after4.py index 2120c7ca09f5..a883b6a1ab04 100644 --- a/python/testData/intentions/demorgan/after4.py +++ b/python/testData/intentions/demorgan/after4.py @@ -4,5 +4,5 @@ c = True d = False #before intention -if not(not(a and b and c) and not d): +if not (not (a and b and c) and not d): print "before" diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index 91cae9e3a812..fde733c7a86c 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -187,6 +187,10 @@ public class PyFormatterTest extends PyTestCase { doTest(); } + public void testSpaceAfterReturn() { + doTest(); + } + public void testPsiFormatting() { // IDEA-69724 String initial = "def method_name(\n" +