diff --git a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java index 04c72473709a..ca144c339570 100644 --- a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java @@ -190,7 +190,7 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase { @NotNull Map parameters, @NotNull Map substitutions, @NotNull TypeEvalContext context) { - if (parameters.size() != 1 || substitutions.size() != 1) { + if (parameters.size() != 1 || substitutions.size() > 1) { return null; } @@ -204,7 +204,8 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase { } if (PyABCUtil.isSubtype(firstArgumentType, PyNames.ABC_INTEGRAL, context)) { - return Ref.create(substitutions.values().iterator().next()); + final PyType result = substitutions.isEmpty() ? null : substitutions.values().iterator().next(); + return Ref.create(result); } if (PyNames.SLICE.equals(firstArgumentType.getName()) && firstArgumentType.isBuiltin()) { diff --git a/python/testSrc/com/jetbrains/python/PyTypingTest.java b/python/testSrc/com/jetbrains/python/PyTypingTest.java index a919ffd0994f..3a7ab45192df 100644 --- a/python/testSrc/com/jetbrains/python/PyTypingTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypingTest.java @@ -691,6 +691,15 @@ public class PyTypingTest extends PyTestCase { " expr = x[y]\n"); } + public void testGetListOfListsItemByIntegral() { + doTest("Any", + "from typing import List\n" + + "\n" + + "def foo(x: List[List]):\n" + + " sublist = x[0]\n" + + " expr = sublist[0]\n"); + } + private void doTestNoInjectedText(@NotNull String text) { myFixture.configureByText(PythonFileType.INSTANCE, text); final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myFixture.getProject());