mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18254 PY-18762 Use homogeneous tuples for annotations like *type inside function type comments
This commit is contained in:
committed by
Andrey Vlasovskikh
parent
5e197a52a3
commit
084c927f45
@@ -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" +
|
||||
|
||||
Reference in New Issue
Block a user