From 084c927f455600438fe42565bf3023a0a8a52b1c Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Mon, 14 Mar 2016 14:54:01 +0300 Subject: [PATCH] PY-18254 PY-18762 Use homogeneous tuples for annotations like *type inside function type comments --- python/src/com/jetbrains/python/psi/types/PyTypeParser.java | 3 +-- python/testSrc/com/jetbrains/python/PyTypeParserTest.java | 2 +- python/testSrc/com/jetbrains/python/PyTypingTest.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/python/src/com/jetbrains/python/psi/types/PyTypeParser.java b/python/src/com/jetbrains/python/psi/types/PyTypeParser.java index cdbc50e9ff33..376d44f20394 100644 --- a/python/src/com/jetbrains/python/psi/types/PyTypeParser.java +++ b/python/src/com/jetbrains/python/psi/types/PyTypeParser.java @@ -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); } diff --git a/python/testSrc/com/jetbrains/python/PyTypeParserTest.java b/python/testSrc/com/jetbrains/python/PyTypeParserTest.java index 30d153e00378..3eb7ec7eb47e 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeParserTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeParserTest.java @@ -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); diff --git a/python/testSrc/com/jetbrains/python/PyTypingTest.java b/python/testSrc/com/jetbrains/python/PyTypingTest.java index 5b22f77f8f69..f86c7aa7c563 100644 --- a/python/testSrc/com/jetbrains/python/PyTypingTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypingTest.java @@ -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" +