PY-27266 Don't use ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION in Python formatter

It is not actually exposed anywhere in Python code style settings and
defaults to false thus affecting parenthesized multiline (chained)
qualified references and calls. Previously, oddly enough, this
behavior was controlled by ALIGN_COLLECTIONS_AND_COMPREHENSIONS flag.
This commit is contained in:
Mikhail Golubev
2017-12-18 19:00:19 +03:00
parent fc7cef68eb
commit 8346c97d60
6 changed files with 23 additions and 1 deletions

View File

@@ -321,7 +321,7 @@ public class PyBlock implements ASTBlock {
// TODO: merge with needChildAlignment()
//Align elements vertically if there is an argument in the first line of parenthesized expression
else if (!hasHangingIndent(myNode.getPsi()) &&
((parentType == PyElementTypes.PARENTHESIZED_EXPRESSION && myContext.getSettings().ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION) ||
(parentType == PyElementTypes.PARENTHESIZED_EXPRESSION ||
(parentType == PyElementTypes.ARGUMENT_LIST && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS) ||
(parentType == PyElementTypes.PARAMETER_LIST && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS)) &&
!isIndentNext(child) &&

View File

@@ -0,0 +1,3 @@
some_var = (Foo
.bar
.baz)

View File

@@ -0,0 +1,3 @@
some_var = (Foo
.bar
.baz)

View File

@@ -0,0 +1,3 @@
some_var = (Foo
.bar()
.baz())

View File

@@ -0,0 +1,3 @@
some_var = (Foo
.bar()
.baz())

View File

@@ -903,4 +903,14 @@ public class PyFormatterTest extends PyTestCase {
public void testVariableAnnotations() {
runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest);
}
// PY-27266
public void testChainedMethodCallsInParentheses() {
doTest();
}
// PY-27266
public void testChainedAttributeAccessInParentheses() {
doTest();
}
}