Ignore __getitem__ for Generic indirect inheritors (PY-27102)

This commit is contained in:
Semyon Proshev
2017-12-20 21:06:41 +03:00
parent efd79f3216
commit 8678782c65
3 changed files with 25 additions and 1 deletions
@@ -36,7 +36,7 @@ class PyTypingInspectionExtension : PyInspectionExtension() {
private fun isGenericItselfOrDescendant(type: PyClassLikeType,
context: TypeEvalContext): Boolean {
return PyTypingTypeProvider.GENERIC_CLASSES.contains(type.classQName) ||
type.getSuperClassTypes(context).any { PyTypingTypeProvider.GENERIC_CLASSES.contains(it.classQName) }
type.getAncestorTypes(context).any { PyTypingTypeProvider.GENERIC_CLASSES.contains(it.classQName) }
}
private fun isBuiltin(type: PyClassLikeType): Boolean {
@@ -0,0 +1,19 @@
import typing
T = typing.TypeVar('T')
class X(typing.Generic[T]):
pass
class Y(X[T]):
pass
class Z(Y[T]):
pass
Z[int]
@@ -215,6 +215,11 @@ public class Py3UnresolvedReferencesInspectionTest extends PyInspectionTestCase
doTest();
}
// PY-27102
public void testTypingGenericIndirectInheritorGetItem() {
doTest();
}
// PY-21655
public void testUsageOfFunctionDecoratedWithAsyncioCoroutine() {
doMultiFileTest("a.py");