mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Support __class_getitem__ (PY-27913)
Update resolve for `[]` on definitions so `__class_getitem__` is supported. Support this method (and `__mro_entries__`) in highlighting and completion. Process it as a static method.
This commit is contained in:
@@ -2348,6 +2348,17 @@ public class PyTypeTest extends PyTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
// PY-27913
|
||||
public void testDunderClassGetItemFirstParameter() {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.PYTHON37,
|
||||
() -> doTest("Type[Foo]",
|
||||
"class Foo:\n" +
|
||||
" def __class_getitem__(cls, item):\n" +
|
||||
" expr = cls")
|
||||
);
|
||||
}
|
||||
|
||||
public void testNoneLiteral() {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.PYTHON34,
|
||||
|
||||
@@ -1211,6 +1211,19 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
// PY-27913
|
||||
public void testDunderClassGetItem() {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.PYTHON37,
|
||||
() -> {
|
||||
final List<String> suggested = doTestByText("class A:\n" +
|
||||
" def __<caret>");
|
||||
assertNotNull(suggested);
|
||||
assertContainsElements(suggested, "__class_getitem__(cls, item)");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/completion";
|
||||
|
||||
@@ -391,6 +391,11 @@ public class PythonHighlightingTest extends PyTestCase {
|
||||
doTest(LanguageLevel.PYTHON37, false, false);
|
||||
}
|
||||
|
||||
// PY-27913
|
||||
public void testDunderClassGetItem() {
|
||||
doTest(LanguageLevel.PYTHON37, false, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static EditorColorsScheme createTemporaryColorScheme() {
|
||||
EditorColorsManager manager = EditorColorsManager.getInstance();
|
||||
|
||||
@@ -54,6 +54,10 @@ public class PythonInspectionsTest extends PyTestCase {
|
||||
doHighlightingTest(PyMethodParametersInspection.class, LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void testPyMethodParametersInspectionClassGetItem() {
|
||||
doHighlightingTest(PyMethodParametersInspection.class, LanguageLevel.PYTHON37);
|
||||
}
|
||||
|
||||
public void testPyNestedDecoratorsInspection() {
|
||||
LocalInspectionTool inspection = new PyNestedDecoratorsInspection();
|
||||
doTest(getTestName(false), inspection);
|
||||
|
||||
+5
@@ -670,6 +670,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
// PY-27913
|
||||
public void testDunderClassGetItem() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON37, this::doTest);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user