mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-45368 Fixed completing 'None' in type annotations
GitOrigin-RevId: fc7e7ff0a03ce41373bac2eedbf3e8b7aaa2ce4d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
848266ad5c
commit
65dee450b8
+8
@@ -323,6 +323,9 @@ public class PyKeywordCompletionContributor extends CompletionContributor implem
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_ELSE_BODY_OF_TRY =
|
||||
psiElement().inside(psiElement(PyStatementList.class).inside(psiElement(PyElsePart.class).inside(PyTryExceptStatement.class)));
|
||||
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_ANNOTATION =
|
||||
psiElement().inside(psiElement(PyAnnotation.class));
|
||||
|
||||
private static final PsiElementPattern.Capture<PsiElement> AFTER_IF = afterStatement(psiElement(PyIfStatement.class).withLastChild(
|
||||
psiElement(PyIfPart.class)));
|
||||
private static final PsiElementPattern.Capture<PsiElement> AFTER_TRY = afterStatement(psiElement(PyTryExceptStatement.class));
|
||||
@@ -644,6 +647,11 @@ public class PyKeywordCompletionContributor extends CompletionContributor implem
|
||||
.and(PY35)
|
||||
.afterLeaf(psiElement().withElementType(PyTokenTypes.IDENTIFIER).withText(PyNames.ASYNC)),
|
||||
new PyKeywordCompletionProvider(PyNames.DEF, PyNames.WITH, PyNames.FOR));
|
||||
extend(CompletionType.BASIC,
|
||||
psiElement()
|
||||
.withLanguage(PythonLanguage.getInstance())
|
||||
.and(IN_ANNOTATION),
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyNames.NONE));
|
||||
}
|
||||
|
||||
private void addAs() {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
|
||||
def foo(x: Union[int, None]):
|
||||
pass
|
||||
@@ -0,0 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
|
||||
def foo(x: Union[int, Non<caret>]):
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
def foo() -> None
|
||||
@@ -0,0 +1 @@
|
||||
def foo() -> Non<caret>
|
||||
@@ -248,4 +248,14 @@ public class PythonKeywordCompletionTest extends PyTestCase {
|
||||
public void testNoForAndYieldInCommentContext() {
|
||||
assertDoesntContain(doTestByTestName(), "for", "yield");
|
||||
}
|
||||
|
||||
// PY-45368
|
||||
public void testNoneInParameterAnnotation() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-45368
|
||||
public void testNoneInReturnAnnotation() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user