mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-16412 Proper use of a smart pointer in case of malformed annotations
Namely, it was mistakenly dereferenced before the document was committed after modifications. Callable types are still not rendered properly in PEP 484 compatible format, but at least they don't lead to PIEAE anymore.
This commit is contained in:
committed by
Andrey Vlasovskikh
parent
eedca22cbb
commit
149eefa75e
+2
-2
@@ -128,10 +128,10 @@ public class PyTypeHintGenerationUtil {
|
||||
final PyAssignmentStatement assignment = (PyAssignmentStatement)target.getParent();
|
||||
final SmartPsiElementPointer<PyAssignmentStatement> pointer = manager.createSmartPsiElementPointer(assignment);
|
||||
addOrUpdateAnnotatedStatement = () -> {
|
||||
return PyUtil.updateDocumentUnblockedAndCommitted(target, document -> {
|
||||
PyUtil.updateDocumentUnblockedAndCommitted(target, document -> {
|
||||
document.insertString(target.getTextRange().getEndOffset(), ": " + info.getAnnotationText());
|
||||
return pointer.getElement();
|
||||
});
|
||||
return pointer.getElement();
|
||||
};
|
||||
}
|
||||
else {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
def func(x):
|
||||
pass
|
||||
|
||||
|
||||
va<caret>r = func
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
from typing import Any, Callable
|
||||
|
||||
|
||||
def func(x):
|
||||
pass
|
||||
|
||||
|
||||
var: Callable[[Any], None] = func
|
||||
+4
@@ -223,6 +223,10 @@ public class PyAnnotateVariableTypeIntentionTest extends PyIntentionTestCase {
|
||||
doAnnotationTest();
|
||||
}
|
||||
|
||||
public void testAnnotationCallableType() {
|
||||
doAnnotationTest();
|
||||
}
|
||||
|
||||
private void doAnnotationTest() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user