PY-35627 Make Python formatter always add a line break after a decorator list

For regular non-async functions, it already worked thanks to PyTokenSeparatorGenerator.

GitOrigin-RevId: b60dba7b34710cad7dc46ad6f943b3944fc00c42
This commit is contained in:
Mikhail Golubev
2024-02-01 13:53:12 +02:00
committed by intellij-monorepo-bot
parent 0a14ce2dea
commit b55fd53258
4 changed files with 12 additions and 1 deletions

View File

@@ -122,7 +122,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilder, Cus
.before(PATTERN_ARGUMENT_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES) .before(PATTERN_ARGUMENT_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES)
.around(DECORATOR_CALL).spacing(1, Integer.MAX_VALUE, 0, true, 0) .around(DECORATOR_CALL).spacing(1, Integer.MAX_VALUE, 0, true, 0)
.after(DECORATOR_LIST).spacing(1, Integer.MAX_VALUE, 0, true, 0) .after(DECORATOR_LIST).spacing(1, Integer.MAX_VALUE, 1, true, 0)
.aroundInside(EQ, ASSIGNMENT_STATEMENT).spaceIf(commonSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS) .aroundInside(EQ, ASSIGNMENT_STATEMENT).spaceIf(commonSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS)
.aroundInside(EQ, TYPE_ALIAS_STATEMENT).spaceIf(commonSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS) .aroundInside(EQ, TYPE_ALIAS_STATEMENT).spaceIf(commonSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS)

View File

@@ -0,0 +1,3 @@
class C:
async def <caret>m(self, p):
return f'{p}'

View File

@@ -0,0 +1,4 @@
class C:
@staticmethod
async def <caret>m(p):
return f'{p}'

View File

@@ -45,4 +45,8 @@ public class PyMakeMethodStaticQuickFixTest extends PyQuickFixTestCase {
doMultifilesTest(PyMethodMayBeStaticInspection.class, PyPsiBundle.message("QFIX.NAME.make.static"), new String[]{"test.py"}); doMultifilesTest(PyMethodMayBeStaticInspection.class, PyPsiBundle.message("QFIX.NAME.make.static"), new String[]{"test.py"});
} }
// PY-35627
public void testAsyncMethod() {
doQuickFixTest(PyMethodMayBeStaticInspection.class, PyPsiBundle.message("QFIX.NAME.make.static"));
}
} }