mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Support incomplete stubs by changing language level to Python 3.7 (PY-22868)
This commit is contained in:
@@ -30,7 +30,7 @@ class PyiFile(viewProvider: FileViewProvider) : PyFileImpl(viewProvider, PyiLang
|
||||
|
||||
override fun toString() = "PyiFile:" + name
|
||||
|
||||
override fun getLanguageLevel() = LanguageLevel.PYTHON36
|
||||
override fun getLanguageLevel() = LanguageLevel.PYTHON37
|
||||
|
||||
override fun multiResolveName(name: String, exported: Boolean): List<RatedResolveResult> {
|
||||
val baseResults = super.multiResolveName(name, exported)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
from complete import a
|
||||
from complete import b
|
||||
from complete import <error descr="Cannot find reference 'e' in 'complete.pyi'">e</error>
|
||||
|
||||
from incomplete import c
|
||||
from incomplete import d
|
||||
|
||||
print(a, b, c, d, e)
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
def a():
|
||||
return 1
|
||||
|
||||
def b():
|
||||
return ""
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def a() -> int: ...
|
||||
def b() -> str: ...
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
def c():
|
||||
return 1
|
||||
|
||||
def d():
|
||||
return ""
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
|
||||
def c() -> int: ...
|
||||
|
||||
def __getattr__(name) -> Any: ...
|
||||
+5
@@ -665,6 +665,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON37, this::doMultiFileTest);
|
||||
}
|
||||
|
||||
// PY-22868
|
||||
public void testStubWithGetAttr() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
@@ -17,7 +17,10 @@ package com.jetbrains.python.pyi;
|
||||
|
||||
import com.intellij.testFramework.ParsingTestCase;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import com.jetbrains.python.*;
|
||||
import com.jetbrains.python.PythonDialectsTokenSetContributor;
|
||||
import com.jetbrains.python.PythonDialectsTokenSetProvider;
|
||||
import com.jetbrains.python.PythonTestUtil;
|
||||
import com.jetbrains.python.PythonTokenSetContributor;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
|
||||
/**
|
||||
@@ -50,6 +53,6 @@ public class PyiParsingTest extends ParsingTestCase {
|
||||
doTest();
|
||||
assertInstanceOf(myFile, PyiFile.class);
|
||||
final PyiFile pyiFile = (PyiFile)myFile;
|
||||
assertEquals(LanguageLevel.PYTHON36, pyiFile.getLanguageLevel());
|
||||
assertEquals(LanguageLevel.PYTHON37, pyiFile.getLanguageLevel());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user