PY-15171 Detect hanging indent in the value of key-value pair in dict literals

This commit is contained in:
Mikhail Golubev
2015-04-27 20:34:48 +03:00
parent 32b76de893
commit 6792b58ce4
4 changed files with 19 additions and 0 deletions
@@ -407,6 +407,10 @@ public class PyBlock implements ASTBlock {
final PyExpression valueExpression = ((PyKeywordArgument)firstItem).getValueExpression();
return valueExpression != null && hasHangingIndent(valueExpression);
}
else if (firstItem instanceof PyKeyValueExpression) {
final PyExpression value = ((PyKeyValueExpression)firstItem).getValue();
return value != null && hasHangingIndent(value);
}
return hasHangingIndent(firstItem);
}
}
@@ -0,0 +1,5 @@
example = {'breakfast': {
'eggs': 1,
'spam': 2
}
}
@@ -0,0 +1,5 @@
example = {'breakfast': {
'eggs': 1,
'spam': 2
}
}
@@ -559,6 +559,11 @@ public class PyFormatterTest extends PyTestCase {
doTest();
}
// PY-15171
public void testHangingIndentInKeyValuePair() {
doTest();
}
public void testAlignmentOfEmptyCollectionLiterals() {
doTest();
}