File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed
python-psi-impl/src/com/jetbrains/python/psi/impl/stubs
testData/inspections/PyTypeHintsInspection/ImplicitTypeAliasAtClassLevelMultiFile
testSrc/com/jetbrains/python/inspections Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 2525import com .jetbrains .python .PyElementTypes ;
2626import com .jetbrains .python .PyTokenTypes ;
2727import com .jetbrains .python .ast .impl .PyUtilCore ;
28+ import com .jetbrains .python .codeInsight .dataflow .scope .ScopeUtil ;
2829import com .jetbrains .python .codeInsight .typing .PyTypingTypeProvider ;
2930import com .jetbrains .python .psi .*;
3031import com .jetbrains .python .psi .resolve .PyResolveUtil ;
@@ -68,7 +69,7 @@ public final class PyTypingAliasStubType extends CustomTargetExpressionStubType<
6869 }
6970
7071 private static @ Nullable PyExpression getAssignedValueIfTypeAliasLike (@ NotNull PyTargetExpression target , boolean forStubCreation ) {
71- if (!PyUtil .isTopLevel (target ) || !looksLikeTypeAliasTarget (target )) {
72+ if (!( PyUtil .isTopLevel (target ) || ScopeUtil . getScopeOwner ( target ) instanceof PyClass ) || !looksLikeTypeAliasTarget (target )) {
7273 return null ;
7374 }
7475 final PyExpression value = target .findAssignedValue ();
Original file line number Diff line number Diff line change 1+ from lib import Baz
2+
3+
4+ def bar (baz : Baz .SOME_TYPE ) -> None : ...
Original file line number Diff line number Diff line change 1+ from typing import Generic , TypeVar
2+
3+ T1 = TypeVar ("T1" )
4+
5+
6+ class Foo (Generic [T1 ]): ...
7+
8+
9+ class Baz :
10+ SOME_TYPE = Foo [int ]
Original file line number Diff line number Diff line change @@ -2957,6 +2957,11 @@ public void testImplicitTypeAliasUsingCallableWithNewStyleUnion() {
29572957 """ );
29582958 }
29592959
2960+ // PY-83700
2961+ public void testImplicitTypeAliasAtClassLevelMultiFile () {
2962+ doMultiFileTest ();
2963+ }
2964+
29602965 @ NotNull
29612966 @ Override
29622967 protected Class <? extends PyInspection > getInspectionClass () {
You can’t perform that action at this time.
0 commit comments