PY-77060 Remove spaces after * and ** in new-style PEP 695 type parameters

(cherry picked from commit cd38f49d0f28894e4f33dbd2fa331eaf895fd70d)

IJ-CR-148110

GitOrigin-RevId: 99164b1b95b89d7c4b729308c02a8d2800c2f20c
This commit is contained in:
Mikhail Golubev
2024-10-29 12:02:54 +02:00
committed by intellij-monorepo-bot
parent b0321520e6
commit 3d7e118c36
4 changed files with 30 additions and 0 deletions

View File

@@ -1361,4 +1361,9 @@ public abstract class PythonCommonFormatterTest extends PythonCommonTestCase {
public void testAlignmentInMultilineTypeParameterListInClassDefinition() {
doTest();
}
// PY-77060
public void testSpaceAfterStarInTypeParameterList() {
doTest();
}
}

View File

@@ -137,6 +137,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilder, Cus
.aroundInside(ADDITIVE_OPERATIONS, BINARY_EXPRESSION).spaceIf(commonSettings.SPACE_AROUND_ADDITIVE_OPERATORS)
.aroundInside(STAR_OPERATORS, STAR_PARAMETERS).none()
.aroundInside(STAR_OPERATORS, STAR_PATTERNS).none()
.aroundInside(STAR_OPERATORS, TYPE_PARAMETER).none()
.between(EXCEPT_KEYWORD, MULT).none()
.between(PERC, TokenSet.create(PERC, IDENTIFIER, EXPRESSION_STATEMENT)).none()
.around(MULTIPLICATIVE_OPERATIONS).spaceIf(commonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)

View File

@@ -0,0 +1,12 @@
from typing import Callable
type A[T, * Ts, ** P] = Callable[P, tuple[*Ts, T]]
def f[T, * Ts, ** P]() -> Callable[P, tuple[*Ts, T]]:
...
class C[T, * Ts, ** P]:
def m(self) -> Callable[P, tuple[*Ts, T]]:
...

View File

@@ -0,0 +1,12 @@
from typing import Callable
type A[T, *Ts, **P] = Callable[P, tuple[*Ts, T]]
def f[T, *Ts, **P]() -> Callable[P, tuple[*Ts, T]]:
...
class C[T, *Ts, **P]:
def m(self) -> Callable[P, tuple[*Ts, T]]:
...