mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-83700 Support implicit type aliases at class level
GitOrigin-RevId: efaf7fb9ae413370f18429859c05f114e6cf4677
This commit is contained in:
committed by
intellij-monorepo-bot
parent
39a5fc5668
commit
60cafd2f61
+2
-1
@@ -24,6 +24,7 @@ import com.intellij.psi.util.*;
|
||||
import com.jetbrains.python.PyElementTypes;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.ast.impl.PyUtilCore;
|
||||
import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveUtil;
|
||||
@@ -67,7 +68,7 @@ public final class PyTypingAliasStubType extends CustomTargetExpressionStubType<
|
||||
}
|
||||
|
||||
private static @Nullable PyExpression getAssignedValueIfTypeAliasLike(@NotNull PyTargetExpression target, boolean forStubCreation) {
|
||||
if (!PyUtil.isTopLevel(target) || !looksLikeTypeAliasTarget(target)) {
|
||||
if (!(PyUtil.isTopLevel(target) || ScopeUtil.getScopeOwner(target) instanceof PyClass) || !looksLikeTypeAliasTarget(target)) {
|
||||
return null;
|
||||
}
|
||||
final PyExpression value = target.findAssignedValue();
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
from lib import Baz
|
||||
|
||||
|
||||
def bar(baz: Baz.SOME_TYPE) -> None: ...
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
T1 = TypeVar("T1")
|
||||
|
||||
|
||||
class Foo(Generic[T1]): ...
|
||||
|
||||
|
||||
class Baz:
|
||||
SOME_TYPE = Foo[int]
|
||||
@@ -3116,6 +3116,11 @@ public class PyTypeHintsInspectionTest extends PyInspectionTestCase {
|
||||
""");
|
||||
}
|
||||
|
||||
// PY-83700
|
||||
public void testImplicitTypeAliasAtClassLevelMultiFile() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user