PY-21515 Always put a single space after "from" keyword

This commit is contained in:
Mikhail Golubev
2017-05-28 19:36:42 -07:00
parent 5c268c27fb
commit d9f652f70d
6 changed files with 28 additions and 1 deletions

View File

@@ -121,7 +121,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
.beforeInside(RPAR, FROM_IMPORT_STATEMENT).spaces(0, pySettings.FROM_IMPORT_NEW_LINE_BEFORE_RIGHT_PARENTHESIS)
.after(COMMA).spaceIf(commonSettings.SPACE_AFTER_COMMA)
.before(COMMA).spaceIf(commonSettings.SPACE_BEFORE_COMMA)
.between(FROM_KEYWORD, DOT).spaces(1)
.after(FROM_KEYWORD).spaces(1)
.between(DOT, IMPORT_KEYWORD).spaces(1)
.around(DOT).spaces(0)
.aroundInside(AT, DECORATOR_CALL).none()

View File

@@ -0,0 +1,6 @@
def g():
yield 42
def f():
yield from g()

View File

@@ -0,0 +1,6 @@
def g():
yield 42
def f():
yield from g()

View File

@@ -0,0 +1,3 @@
from sys import path
print(sys.path)

View File

@@ -0,0 +1,3 @@
from sys import path
print(sys.path)

View File

@@ -809,6 +809,15 @@ public class PyFormatterTest extends PyTestCase {
runWithLanguageLevel(LanguageLevel.PYTHON30, this::doTest);
}
// PY-21515
public void testSpacesBeforeFromImportSource() {
doTest();
}
public void testSpacesAfterFromInYieldFrom() {
runWithLanguageLevel(LanguageLevel.PYTHON33, this::doTest);
}
public void testVariableAnnotations() {
runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest);
}