PY-21350 Fixed: Wrong return type for input() in Python 3

Add skeletons for raw_input() in Python 2 and input() for both Pythons.
Update PyUserSkeletonsTypeProvider to wrap callable's return type even if it's null.
This commit is contained in:
Semyon Proshev
2016-11-17 20:09:32 +03:00
parent 82f2bd2d1b
commit e87b053584
10 changed files with 77 additions and 5 deletions
@@ -443,7 +443,7 @@ public class Py3TypeTest extends PyTestCase {
// PY-20073
public void testMapReturnType() {
doTest("int",
doTest("int",
"for x in map(lambda x: 42, 'foo'):\n" +
" expr = x");
}
@@ -459,6 +459,12 @@ public class Py3TypeTest extends PyTestCase {
"expr = get_value([])");
}
// PY-21350
public void testBuiltinInput() {
doTest("str",
"expr = input()");
}
private void doTest(final String expectedType, final String text) {
myFixture.configureByText(PythonFileType.INSTANCE, text);
final PyExpression expr = myFixture.findElementByText("expr", PyExpression.class);
@@ -1416,6 +1416,18 @@ public class PyTypeTest extends PyTestCase {
"expr = get_value([])");
}
// PY-21350
public void testBuiltinInput() {
doTest("Any",
"expr = input()");
}
// PY-21350
public void testBuiltinRawInput() {
doTest("str",
"expr = raw_input()");
}
private static List<TypeEvalContext> getTypeEvalContexts(@NotNull PyExpression element) {
return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(),
TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());
@@ -178,4 +178,9 @@ public class Py3TypeCheckerInspectionTest extends PyTestCase {
public void testMapArgumentsInOppositeOrder() {
doTest();
}
// PY-21350
public void testBuiltinInputPy3() {
doTest();
}
}
@@ -350,4 +350,14 @@ public class PyTypeCheckerInspectionTest extends PyTestCase {
public void testPositionalArguments() {
doTest();
}
// PY-21350
public void testBuiltinInputPy2() {
doTest();
}
// PY-21350
public void testBuiltinRawInput() {
doTest();
}
}