diff --git a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java index 28b16126f316..46317138c123 100644 --- a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java +++ b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java @@ -80,6 +80,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C .after(COMMA).spaceIf(commonSettings.SPACE_AFTER_COMMA) .before(COMMA).spaceIf(commonSettings.SPACE_BEFORE_COMMA) .between(FROM_KEYWORD, DOT).spaces(1) + .between(DOT, IMPORT_KEYWORD).spaces(1) .around(DOT).spaces(0) .before(SEMICOLON).spaceIf(commonSettings.SPACE_BEFORE_SEMICOLON) .withinPairInside(LPAR, RPAR, ARGUMENT_LIST).spaceIf(commonSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES) diff --git a/python/testData/formatter/spaceAfterRelativeImport.py b/python/testData/formatter/spaceAfterRelativeImport.py new file mode 100644 index 000000000000..d163a992484b --- /dev/null +++ b/python/testData/formatter/spaceAfterRelativeImport.py @@ -0,0 +1 @@ +from . import x diff --git a/python/testData/formatter/spaceAfterRelativeImport_after.py b/python/testData/formatter/spaceAfterRelativeImport_after.py new file mode 100644 index 000000000000..d163a992484b --- /dev/null +++ b/python/testData/formatter/spaceAfterRelativeImport_after.py @@ -0,0 +1 @@ +from . import x diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index fde733c7a86c..45c004149522 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -191,6 +191,10 @@ public class PyFormatterTest extends PyTestCase { doTest(); } + public void testSpaceAfterRelativeImport() { // PY-8112 + doTest(); + } + public void testPsiFormatting() { // IDEA-69724 String initial = "def method_name(\n" +