mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
PY-73246 Don't insert square brackets after classes not having free type parameters
Even if they transitively extend typing.Generic, such as the builtin str. GitOrigin-RevId: 9389ef5846e21ba5e0fed8b835beb2d458e42f13
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ebba681c85
commit
eb63148798
@@ -19,7 +19,7 @@ public class PyParameterizedTypeInsertHandler extends ParenthesesInsertHandler<L
|
||||
public static boolean isCompletingParameterizedType(@NotNull PsiElement definition,
|
||||
@NotNull PsiElement completionPosition,
|
||||
@NotNull TypeEvalContext context) {
|
||||
return PyTypingTypeProvider.isInsideTypeHint(completionPosition, context) && isParameterizedType(definition, context);
|
||||
return PyTypingTypeProvider.isInsideTypeHint(completionPosition, context) && isParameterizableType(definition, context);
|
||||
}
|
||||
|
||||
public static final PyParameterizedTypeInsertHandler INSTANCE = new PyParameterizedTypeInsertHandler();
|
||||
@@ -33,8 +33,8 @@ public class PyParameterizedTypeInsertHandler extends ParenthesesInsertHandler<L
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isParameterizedType(@NotNull PsiElement element, @NotNull TypeEvalContext typeEvalContext) {
|
||||
private static boolean isParameterizableType(@NotNull PsiElement element, @NotNull TypeEvalContext typeEvalContext) {
|
||||
return element instanceof PyQualifiedNameOwner qnOwner && PyTypingTypeProvider.GENERIC_CLASSES.contains(qnOwner.getQualifiedName()) ||
|
||||
element instanceof PyClass pyClass && PyTypingTypeProvider.isGeneric(pyClass, typeEvalContext);
|
||||
element instanceof PyClass pyClass && new PyTypingTypeProvider().getGenericType(pyClass, typeEvalContext) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
from typing import Iterable
|
||||
|
||||
|
||||
class StrIterable(Iterable[str]):
|
||||
pass
|
||||
|
||||
|
||||
x: StrIterable
|
||||
@@ -0,0 +1,8 @@
|
||||
from typing import Iterable
|
||||
|
||||
|
||||
class StrIterable(Iterable[str]):
|
||||
pass
|
||||
|
||||
|
||||
x: StrIter<caret>
|
||||
@@ -743,6 +743,11 @@ public class Py3CompletionTest extends PyTestCase {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
// PY-73246
|
||||
public void testSquareBracketsNotInsertedAfterAlreadyParameterizedGenericInsideTypeHints() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
private void doTestVariants(String @NotNull ... expected) {
|
||||
final String testName = getTestName(true);
|
||||
myFixture.configureByFile(testName + ".py");
|
||||
|
||||
Reference in New Issue
Block a user