PY-18254 PY-18762 Use homogeneous tuples for annotations like *type inside function type comments

This commit is contained in:
Mikhail Golubev
2016-03-17 18:40:27 +03:00
committed by Andrey Vlasovskikh
parent 5e197a52a3
commit 084c927f45
3 changed files with 3 additions and 4 deletions
@@ -409,8 +409,7 @@ public class PyTypeParser {
return paramResult;
}
else if (starCount == 1) {
final PyClassType tupleType = PyBuiltinCache.getInstance(anchor).getTupleType();
// TODO How to represent unbound homogeneous tuple?
final PyClassType tupleType = PyTupleType.createHomogeneous(anchor, type);
if (tupleType != null) {
return paramResult.withType(tupleType);
}
@@ -293,7 +293,7 @@ public class PyTypeParserTest extends PyTestCase {
final PyClassType type3 = as(parameterTypes.get(2).getType(context), PyClassType.class);
assertNotNull(type3);
assertEquals("tuple", type3.getName());
assertEquals("(str, ...)", type3.getName());
final PyCollectionType type4 = as(parameterTypes.get(3).getType(context), PyCollectionType.class);
assertNotNull(type4);
@@ -451,7 +451,7 @@ public class PyTypingTest extends PyTestCase {
// PY-18254
public void testFunctionTypeComment() {
doTest("(x: int, args: tuple, kwargs: Dict[str, str]) -> List[bool]",
doTest("(x: int, args: Tuple[float, ...], kwargs: Dict[str, str]) -> List[bool]",
"from typing import List\n" +
"\n" +
"def f(x, *args, **kwargs):\n" +