mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18816 Test that accessing annotation in type declarations doesn't cause unstubbing
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class MyClass:
|
||||
foo: str
|
||||
|
||||
def __init__(self):
|
||||
self.bar: int
|
||||
@@ -1 +1,2 @@
|
||||
x: int = ...
|
||||
x: int = ...
|
||||
y: str
|
||||
@@ -755,11 +755,33 @@ public class PyStubsTest extends PyTestCase {
|
||||
public void testVariableAnnotation() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON36, () -> {
|
||||
final PyFile file = getTestFile();
|
||||
final PyTargetExpression var = file.findTopLevelAttribute("x");
|
||||
final String annotation = var.getAnnotationValue();
|
||||
assertEquals("int", annotation);
|
||||
final PyTargetExpression assignmentTarget = file.findTopLevelAttribute("x");
|
||||
final String assignmentAnnotation = assignmentTarget.getAnnotationValue();
|
||||
assertEquals("int", assignmentAnnotation);
|
||||
assertNotParsed(file);
|
||||
assertType("int", var, TypeEvalContext.codeInsightFallback(myFixture.getProject()));
|
||||
assertType("int", assignmentTarget, TypeEvalContext.codeInsightFallback(myFixture.getProject()));
|
||||
assertNotParsed(file);
|
||||
|
||||
final PyTargetExpression typeDecTarget = file.findTopLevelAttribute("y");
|
||||
final String typeDecAnnotation = typeDecTarget.getAnnotationValue();
|
||||
assertEquals("str", typeDecAnnotation);
|
||||
assertNotParsed(file);
|
||||
assertType("str", typeDecTarget, TypeEvalContext.codeInsightFallback(myFixture.getProject()));
|
||||
assertNotParsed(file);
|
||||
});
|
||||
}
|
||||
|
||||
// PY-18116
|
||||
public void testAttributeTypeDeclaration() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON36, () -> {
|
||||
final PyFile file = getTestFile();
|
||||
final PyClass pyClass = file.findTopLevelClass("MyClass");
|
||||
final TypeEvalContext context = TypeEvalContext.codeInsightFallback(myFixture.getProject());
|
||||
final PyTargetExpression classAttr = pyClass.findClassAttribute("foo", false, context);
|
||||
assertType("str", classAttr, context);
|
||||
|
||||
final PyTargetExpression instAttr = pyClass.findInstanceAttribute("bar", false);
|
||||
assertType("int", instAttr, context);
|
||||
assertNotParsed(file);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user