mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Update PyStdlibTypeProvider to return "Any" as list element type if list generic is not specified
This commit is contained in:
@@ -190,7 +190,7 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase {
|
||||
@NotNull Map<PyExpression, PyNamedParameter> parameters,
|
||||
@NotNull Map<PyGenericType, PyType> 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()) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user