PY-21692 Fixed: Return type of sum(List[Decimal]) is 'Any' (should be 'Decimal')

Add skeletons for builtin sum function
This commit is contained in:
Semyon Proshev
2016-11-29 20:32:25 +03:00
parent 60edb30580
commit e3f371128b
4 changed files with 32 additions and 0 deletions
@@ -229,6 +229,16 @@ def max(*args, key=None, default=None):
pass
def sum(iterable, start=0):
"""Sums start and the items of an iterable from left to right and returns
the total.
:type iterable: collections.Iterable[T]
:rtype: T
"""
pass
def next(iterator, default=None):
"""Return the next item from the iterator.
@@ -232,6 +232,16 @@ def max(*args, key=None, default=None):
pass
def sum(iterable, start=0):
"""Sums start and the items of an iterable from left to right and returns
the total.
:type iterable: collections.Iterable[T]
:rtype: T
"""
pass
def next(iterator, default=None):
"""Return the next item from the iterator.
@@ -475,6 +475,12 @@ public class Py3TypeTest extends PyTestCase {
"expr = max(1, 2, 3)");
}
// PY-21692
public void testSumResult() {
doTest("int",
"expr = sum([1, 2, 3])");
}
private void doTest(final String expectedType, final String text) {
myFixture.configureByText(PythonFileType.INSTANCE, text);
final PyExpression expr = myFixture.findElementByText("expr", PyExpression.class);
@@ -1524,6 +1524,12 @@ public class PyTypeTest extends PyTestCase {
"expr = max(1, 2, 3)");
}
// PY-21692
public void testSumResult() {
doTest("int",
"expr = sum([1, 2, 3])");
}
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());