diff --git a/mypy/types.py b/mypy/types.py index 14eefea7dd81..8583f17a30dd 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -1485,7 +1485,7 @@ class TupleType(ProperType): Instance variables: items: Tuple item types partial_fallback: The (imprecise) underlying instance type that is used - for non-tuple methods. This is generally builtins.tuple[Any] for + for non-tuple methods. This is generally builtins.tuple[Any, ...] for regular tuples, but it's different for named tuples and classes with a tuple base class. Use mypy.typeops.tuple_fallback to calculate the precise fallback type derived from item types. @@ -2203,7 +2203,11 @@ def visit_instance(self, t: Instance) -> str: if t.erased: s += '*' if t.args: - s += '[{}]'.format(self.list_str(t.args)) + if t.type.fullname == 'builtins.tuple': + assert len(t.args) == 1 + s += '[{}, ...]'.format(self.list_str(t.args)) + else: + s += '[{}]'.format(self.list_str(t.args)) if self.id_mapper: s += '<{}>'.format(self.id_mapper.id(t.type)) return s diff --git a/test-data/unit/check-annotated.test b/test-data/unit/check-annotated.test index 68862087d13d..d4309b8ad213 100644 --- a/test-data/unit/check-annotated.test +++ b/test-data/unit/check-annotated.test @@ -87,7 +87,7 @@ from typing import Tuple from typing_extensions import Annotated Alias = Annotated[Tuple[int, ...], ...] x: Alias -reveal_type(x) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(x) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/tuple.pyi] [case testAnnotatedAliasTypeVar] diff --git a/test-data/unit/check-fastparse.test b/test-data/unit/check-fastparse.test index e2dc4f203855..b30581f0cfd3 100644 --- a/test-data/unit/check-fastparse.test +++ b/test-data/unit/check-fastparse.test @@ -154,7 +154,7 @@ def f(a, # type: A ): reveal_type(a) # N: Revealed type is "__main__.A" reveal_type(b) # N: Revealed type is "Union[__main__.B, None]" - reveal_type(args) # N: Revealed type is "builtins.tuple[__main__.C]" + reveal_type(args) # N: Revealed type is "builtins.tuple[__main__.C, ...]" reveal_type(d) # N: Revealed type is "Union[__main__.D, None]" reveal_type(e) # N: Revealed type is "__main__.E" reveal_type(kwargs) # N: Revealed type is "builtins.dict[builtins.str, __main__.F]" @@ -179,7 +179,7 @@ def f(a, # type: A # type: (...) -> int reveal_type(a) # N: Revealed type is "__main__.A" reveal_type(b) # N: Revealed type is "Union[__main__.B, None]" - reveal_type(args) # N: Revealed type is "builtins.tuple[__main__.C]" + reveal_type(args) # N: Revealed type is "builtins.tuple[__main__.C, ...]" reveal_type(d) # N: Revealed type is "Union[__main__.D, None]" reveal_type(e) # N: Revealed type is "__main__.E" reveal_type(kwargs) # N: Revealed type is "builtins.dict[builtins.str, __main__.F]" @@ -221,7 +221,7 @@ def f(a, # type: A ): reveal_type(a) # N: Revealed type is "__main__.A" reveal_type(b) # N: Revealed type is "Union[__main__.B, None]" - reveal_type(args) # N: Revealed type is "builtins.tuple[__main__.C]" + reveal_type(args) # N: Revealed type is "builtins.tuple[__main__.C, ...]" [builtins fixtures/dict.pyi] [out] @@ -239,7 +239,7 @@ def f(a, # type: A # type: (...) -> int reveal_type(a) # N: Revealed type is "__main__.A" reveal_type(b) # N: Revealed type is "Union[__main__.B, None]" - reveal_type(args) # N: Revealed type is "builtins.tuple[__main__.C]" + reveal_type(args) # N: Revealed type is "builtins.tuple[__main__.C, ...]" return "not an int" # E: Incompatible return value type (got "str", expected "int") [builtins fixtures/dict.pyi] [out] diff --git a/test-data/unit/check-generic-alias.test b/test-data/unit/check-generic-alias.test index b6060f3922fe..7000a145e4d1 100644 --- a/test-data/unit/check-generic-alias.test +++ b/test-data/unit/check-generic-alias.test @@ -101,12 +101,12 @@ t11: type[int] reveal_type(t1) # N: Revealed type is "builtins.list[Any]" reveal_type(t2) # N: Revealed type is "builtins.list[builtins.int]" reveal_type(t3) # N: Revealed type is "builtins.list[builtins.str]" -reveal_type(t4) # N: Revealed type is "builtins.tuple[Any]" +reveal_type(t4) # N: Revealed type is "builtins.tuple[Any, ...]" # TODO: ideally these would reveal builtins.tuple reveal_type(t5) # N: Revealed type is "Tuple[builtins.int]" reveal_type(t6) # N: Revealed type is "Tuple[builtins.int, builtins.str]" # TODO: this is incorrect, see #9522 -reveal_type(t7) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(t7) # N: Revealed type is "builtins.tuple[builtins.int, ...]" reveal_type(t8) # N: Revealed type is "builtins.dict[Any, Any]" reveal_type(t9) # N: Revealed type is "builtins.dict[builtins.int, builtins.str]" reveal_type(t10) # N: Revealed type is "builtins.type" @@ -252,13 +252,13 @@ B = tuple[int, str] x: B = (1, 'x') y: B = ('x', 1) # E: Incompatible types in assignment (expression has type "Tuple[str, int]", variable has type "Tuple[int, str]") -reveal_type(tuple[int, ...]()) # N: Revealed type is "builtins.tuple[builtins.int*]" +reveal_type(tuple[int, ...]()) # N: Revealed type is "builtins.tuple[builtins.int*, ...]" [builtins fixtures/tuple.pyi] [case testTypeAliasWithBuiltinTupleInStub] # flags: --python-version 3.6 import m -reveal_type(m.a) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(m.a) # N: Revealed type is "builtins.tuple[builtins.int, ...]" reveal_type(m.b) # N: Revealed type is "Tuple[builtins.int, builtins.str]" [file m.pyi] diff --git a/test-data/unit/check-generics.test b/test-data/unit/check-generics.test index ed0b680e21aa..61f6f6a7836b 100644 --- a/test-data/unit/check-generics.test +++ b/test-data/unit/check-generics.test @@ -2073,9 +2073,9 @@ class Base(Generic[T]): return (cls(item),) return cls(item) -reveal_type(Base.make_some) # N: Revealed type is "Overload(def [T] (item: T`1) -> __main__.Base[T`1], def [T] (item: T`1, n: builtins.int) -> builtins.tuple[__main__.Base[T`1]])" +reveal_type(Base.make_some) # N: Revealed type is "Overload(def [T] (item: T`1) -> __main__.Base[T`1], def [T] (item: T`1, n: builtins.int) -> builtins.tuple[__main__.Base[T`1], ...])" reveal_type(Base.make_some(1)) # N: Revealed type is "__main__.Base[builtins.int*]" -reveal_type(Base.make_some(1, 1)) # N: Revealed type is "builtins.tuple[__main__.Base[builtins.int*]]" +reveal_type(Base.make_some(1, 1)) # N: Revealed type is "builtins.tuple[__main__.Base[builtins.int*], ...]" class Sub(Base[str]): ... Sub.make_some(1) # E: No overload variant of "make_some" of "Base" matches argument type "int" \ @@ -2183,7 +2183,7 @@ class C(Generic[T]): class D(C[str]): ... reveal_type(D.get()) # N: Revealed type is "builtins.str*" -reveal_type(D.get(42)) # N: Revealed type is "builtins.tuple[builtins.str*]" +reveal_type(D.get(42)) # N: Revealed type is "builtins.tuple[builtins.str*, ...]" [builtins fixtures/classmethod.pyi] [case testGenericClassMethodAnnotation] diff --git a/test-data/unit/check-namedtuple.test b/test-data/unit/check-namedtuple.test index 440884333c69..5d28d78013f4 100644 --- a/test-data/unit/check-namedtuple.test +++ b/test-data/unit/check-namedtuple.test @@ -673,7 +673,7 @@ Node = NamedTuple('Node', [ ('children', Tuple['Node', ...]), # E: Cannot resolve name "Node" (possible cyclic definition) ]) n: Node -reveal_type(n) # N: Revealed type is "Tuple[builtins.str, builtins.tuple[Any], fallback=__main__.Node]" +reveal_type(n) # N: Revealed type is "Tuple[builtins.str, builtins.tuple[Any, ...], fallback=__main__.Node]" [builtins fixtures/tuple.pyi] [case testSelfRefNT2] @@ -689,7 +689,7 @@ class B(NamedTuple): y: int n: A -reveal_type(n) # N: Revealed type is "Tuple[builtins.str, builtins.tuple[Any], fallback=__main__.A]" +reveal_type(n) # N: Revealed type is "Tuple[builtins.str, builtins.tuple[Any, ...], fallback=__main__.A]" [builtins fixtures/tuple.pyi] [case testSelfRefNT3] diff --git a/test-data/unit/check-overloading.test b/test-data/unit/check-overloading.test index d903c895c45c..d13b5fc4b3e6 100644 --- a/test-data/unit/check-overloading.test +++ b/test-data/unit/check-overloading.test @@ -2589,12 +2589,12 @@ def f(*args): pass i: int reveal_type(f(i)) # N: Revealed type is "Tuple[builtins.int]" reveal_type(f(i, i)) # N: Revealed type is "Tuple[builtins.int, builtins.int]" -reveal_type(f(i, i, i)) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(f(i, i, i)) # N: Revealed type is "builtins.tuple[builtins.int, ...]" -reveal_type(f(*[])) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(f(*[i])) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(f(*[i, i])) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(f(*[i, i, i])) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(f(*[])) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(f(*[i])) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(f(*[i, i])) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(f(*[i, i, i])) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/list.pyi] [case testOverloadVarargsSelectionWithTuples] @@ -2608,10 +2608,10 @@ def f(*xs: int) -> Tuple[int, ...]: ... def f(*args): pass i: int -reveal_type(f(*())) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(f(*())) # N: Revealed type is "builtins.tuple[builtins.int, ...]" reveal_type(f(*(i,))) # N: Revealed type is "Tuple[builtins.int]" reveal_type(f(*(i, i))) # N: Revealed type is "Tuple[builtins.int, builtins.int]" -reveal_type(f(*(i, i, i))) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(f(*(i, i, i))) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/tuple.pyi] [case testOverloadVarargsSelectionWithNamedTuples] @@ -2631,7 +2631,7 @@ b: B c: C reveal_type(f(*a)) # N: Revealed type is "Tuple[builtins.int, builtins.int]" reveal_type(f(*b)) # N: Revealed type is "Tuple[builtins.int, builtins.int]" -reveal_type(f(*c)) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(f(*c)) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/tuple.pyi] [case testOverloadKwargsSelectionWithDict] @@ -2645,10 +2645,10 @@ def f(**xs: int) -> Tuple[int, ...]: ... def f(**kwargs): pass empty: Dict[str, int] -reveal_type(f(**empty)) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(f(**{'x': 4})) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(f(**{'x': 4, 'y': 4})) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(f(**{'a': 4, 'b': 4, 'c': 4})) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(f(**empty)) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(f(**{'x': 4})) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(f(**{'x': 4, 'y': 4})) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(f(**{'a': 4, 'b': 4, 'c': 4})) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/dict.pyi] [case testOverloadKwargsSelectionWithTypedDict] @@ -2672,7 +2672,7 @@ c: C reveal_type(f(**a)) # N: Revealed type is "Tuple[builtins.int]" reveal_type(f(**b)) # N: Revealed type is "Tuple[builtins.int, builtins.int]" -reveal_type(f(**c)) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(f(**c)) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/dict.pyi] [case testOverloadVarargsAndKwargsSelection] diff --git a/test-data/unit/check-selftype.test b/test-data/unit/check-selftype.test index afd75111743d..3948d215b192 100644 --- a/test-data/unit/check-selftype.test +++ b/test-data/unit/check-selftype.test @@ -555,9 +555,9 @@ reveal_type(P) # N: Revealed type is "Overload(def [T] (use_str: Literal[True]) reveal_type(P(use_str=True)) # N: Revealed type is "lib.P[builtins.str]" reveal_type(P(use_str=False)) # N: Revealed type is "lib.P[builtins.int]" -reveal_type(C) # N: Revealed type is "Overload(def [T] (item: T`1, use_tuple: Literal[False]) -> lib.C[T`1], def [T] (item: T`1, use_tuple: Literal[True]) -> lib.C[builtins.tuple[T`1]])" +reveal_type(C) # N: Revealed type is "Overload(def [T] (item: T`1, use_tuple: Literal[False]) -> lib.C[T`1], def [T] (item: T`1, use_tuple: Literal[True]) -> lib.C[builtins.tuple[T`1, ...]])" reveal_type(C(0, use_tuple=False)) # N: Revealed type is "lib.C[builtins.int*]" -reveal_type(C(0, use_tuple=True)) # N: Revealed type is "lib.C[builtins.tuple[builtins.int*]]" +reveal_type(C(0, use_tuple=True)) # N: Revealed type is "lib.C[builtins.tuple[builtins.int*, ...]]" T = TypeVar('T') class SubP(P[T]): @@ -949,9 +949,9 @@ class Other(Base): ... class Double(Sub): ... reveal_type(Other.make()) # N: Revealed type is "__main__.Other*" -reveal_type(Other.make(3)) # N: Revealed type is "builtins.tuple[__main__.Other*]" +reveal_type(Other.make(3)) # N: Revealed type is "builtins.tuple[__main__.Other*, ...]" reveal_type(Double.make()) # N: Revealed type is "__main__.Sub" -reveal_type(Double.make(3)) # N: Revealed type is "builtins.tuple[__main__.Sub]" +reveal_type(Double.make(3)) # N: Revealed type is "builtins.tuple[__main__.Sub, ...]" [file lib.pyi] from typing import overload, TypeVar, Type, Tuple diff --git a/test-data/unit/check-serialize.test b/test-data/unit/check-serialize.test index b34a6c704a27..3a9d2266dd55 100644 --- a/test-data/unit/check-serialize.test +++ b/test-data/unit/check-serialize.test @@ -1030,8 +1030,8 @@ x: Tuple[int, ...] y: tuple [builtins fixtures/tuple.pyi] [out2] -tmp/a.py:2: note: Revealed type is "builtins.tuple[builtins.int]" -tmp/a.py:3: note: Revealed type is "builtins.tuple[Any]" +tmp/a.py:2: note: Revealed type is "builtins.tuple[builtins.int, ...]" +tmp/a.py:3: note: Revealed type is "builtins.tuple[Any, ...]" [case testSerializeNone] import a diff --git a/test-data/unit/check-tuples.test b/test-data/unit/check-tuples.test index 6c4c63dc5c2d..b558e1520798 100644 --- a/test-data/unit/check-tuples.test +++ b/test-data/unit/check-tuples.test @@ -193,7 +193,7 @@ t1[2] # E: Tuple index out of range t1[3] # E: Tuple index out of range t2[1] # E: Tuple index out of range reveal_type(t1[n]) # N: Revealed type is "Union[__main__.A, __main__.B]" -reveal_type(t3[n:]) # N: Revealed type is "builtins.tuple[Union[__main__.A, __main__.B, __main__.C, __main__.D, __main__.E]]" +reveal_type(t3[n:]) # N: Revealed type is "builtins.tuple[Union[__main__.A, __main__.B, __main__.C, __main__.D, __main__.E], ...]" if int(): b = t1[(0)] # E: Incompatible types in assignment (expression has type "A", variable has type "B") @@ -985,15 +985,15 @@ reveal_type(b) # N: Revealed type is "Tuple[builtins.int, builtins.int, builtin [case testTupleWithStarExpr2] a = [1] b = (0, *a) -reveal_type(b) # N: Revealed type is "builtins.tuple[builtins.int*]" +reveal_type(b) # N: Revealed type is "builtins.tuple[builtins.int*, ...]" [builtins fixtures/tuple.pyi] [case testTupleWithStarExpr3] a = [''] b = (0, *a) -reveal_type(b) # N: Revealed type is "builtins.tuple[builtins.object*]" +reveal_type(b) # N: Revealed type is "builtins.tuple[builtins.object*, ...]" c = (*a, '') -reveal_type(c) # N: Revealed type is "builtins.tuple[builtins.str*]" +reveal_type(c) # N: Revealed type is "builtins.tuple[builtins.str*, ...]" [builtins fixtures/tuple.pyi] [case testTupleWithStarExpr4] @@ -1086,12 +1086,12 @@ class B(A): pass fixtup = None # type: Tuple[B, B] vartup_b = None # type: Tuple[B, ...] -reveal_type(fixtup if int() else vartup_b) # N: Revealed type is "builtins.tuple[__main__.B]" -reveal_type(vartup_b if int() else fixtup) # N: Revealed type is "builtins.tuple[__main__.B]" +reveal_type(fixtup if int() else vartup_b) # N: Revealed type is "builtins.tuple[__main__.B, ...]" +reveal_type(vartup_b if int() else fixtup) # N: Revealed type is "builtins.tuple[__main__.B, ...]" vartup_a = None # type: Tuple[A, ...] -reveal_type(fixtup if int() else vartup_a) # N: Revealed type is "builtins.tuple[__main__.A]" -reveal_type(vartup_a if int() else fixtup) # N: Revealed type is "builtins.tuple[__main__.A]" +reveal_type(fixtup if int() else vartup_a) # N: Revealed type is "builtins.tuple[__main__.A, ...]" +reveal_type(vartup_a if int() else fixtup) # N: Revealed type is "builtins.tuple[__main__.A, ...]" [builtins fixtures/tuple.pyi] @@ -1124,12 +1124,12 @@ class A: pass empty = () fixtup = None # type: Tuple[A] -reveal_type(fixtup if int() else empty) # N: Revealed type is "builtins.tuple[__main__.A]" -reveal_type(empty if int() else fixtup) # N: Revealed type is "builtins.tuple[__main__.A]" +reveal_type(fixtup if int() else empty) # N: Revealed type is "builtins.tuple[__main__.A, ...]" +reveal_type(empty if int() else fixtup) # N: Revealed type is "builtins.tuple[__main__.A, ...]" vartup = None # type: Tuple[A, ...] -reveal_type(empty if int() else vartup) # N: Revealed type is "builtins.tuple[__main__.A]" -reveal_type(vartup if int() else empty) # N: Revealed type is "builtins.tuple[__main__.A]" +reveal_type(empty if int() else vartup) # N: Revealed type is "builtins.tuple[__main__.A, ...]" +reveal_type(vartup if int() else empty) # N: Revealed type is "builtins.tuple[__main__.A, ...]" lst = None # type: List[A] reveal_type(empty if int() else lst) # N: Revealed type is "typing.Sequence[__main__.A*]" @@ -1152,8 +1152,8 @@ ntup = None # type: NTup subtup = None # type: SubTuple vartup = None # type: SubVarTuple -reveal_type(ntup if int() else vartup) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(subtup if int() else vartup) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(ntup if int() else vartup) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(subtup if int() else vartup) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/tuple.pyi] [out] @@ -1164,14 +1164,14 @@ from typing import Tuple tup1 = None # type: Tuple[bool, int] tup2 = None # type: Tuple[bool] -reveal_type(tup1 if int() else tup2) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(tup2 if int() else tup1) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(tup1 if int() else tup2) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(tup2 if int() else tup1) # N: Revealed type is "builtins.tuple[builtins.int, ...]" -reveal_type(tup1 if int() else ()) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(() if int() else tup1) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(tup1 if int() else ()) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(() if int() else tup1) # N: Revealed type is "builtins.tuple[builtins.int, ...]" -reveal_type(tup2 if int() else ()) # N: Revealed type is "builtins.tuple[builtins.bool]" -reveal_type(() if int() else tup2) # N: Revealed type is "builtins.tuple[builtins.bool]" +reveal_type(tup2 if int() else ()) # N: Revealed type is "builtins.tuple[builtins.bool, ...]" +reveal_type(() if int() else tup2) # N: Revealed type is "builtins.tuple[builtins.bool, ...]" [builtins fixtures/tuple.pyi] [out] @@ -1192,14 +1192,14 @@ tup1 = None # type: NTup1 tup2 = None # type: NTup2 subtup = None # type: SubTuple -reveal_type(tup1 if int() else tup2) # N: Revealed type is "builtins.tuple[builtins.bool]" -reveal_type(tup2 if int() else tup1) # N: Revealed type is "builtins.tuple[builtins.bool]" +reveal_type(tup1 if int() else tup2) # N: Revealed type is "builtins.tuple[builtins.bool, ...]" +reveal_type(tup2 if int() else tup1) # N: Revealed type is "builtins.tuple[builtins.bool, ...]" -reveal_type(tup1 if int() else subtup) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(subtup if int() else tup1) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(tup1 if int() else subtup) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(subtup if int() else tup1) # N: Revealed type is "builtins.tuple[builtins.int, ...]" -reveal_type(tup2 if int() else subtup) # N: Revealed type is "builtins.tuple[builtins.int]" -reveal_type(subtup if int() else tup2) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(tup2 if int() else subtup) # N: Revealed type is "builtins.tuple[builtins.int, ...]" +reveal_type(subtup if int() else tup2) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/tuple.pyi] [out] @@ -1263,7 +1263,7 @@ t[y] # E: Invalid tuple index type (actual type "str", expected type "Union[int t = (0, "") x = 0 y = "" -reveal_type(t[x:]) # N: Revealed type is "builtins.tuple[Union[builtins.int, builtins.str]]" +reveal_type(t[x:]) # N: Revealed type is "builtins.tuple[Union[builtins.int, builtins.str], ...]" t[y:] # E: Slice index must be an integer or None [builtins fixtures/tuple.pyi] @@ -1311,7 +1311,7 @@ class CallableTuple(Tuple[str, int]): from typing import Sequence s: Sequence[str] s = tuple() -reveal_type(s) # N: Revealed type is "builtins.tuple[builtins.str]" +reveal_type(s) # N: Revealed type is "builtins.tuple[builtins.str, ...]" [builtins fixtures/tuple.pyi] @@ -1320,7 +1320,7 @@ from typing import Iterable, Tuple x: Iterable[int] = () y: Tuple[int, ...] = (1, 2, 3) x = y -reveal_type(x) # N: Revealed type is "builtins.tuple[builtins.int]" +reveal_type(x) # N: Revealed type is "builtins.tuple[builtins.int, ...]" [builtins fixtures/tuple.pyi] @@ -1481,7 +1481,7 @@ t3 = ('', 1) * 2 reveal_type(t3) # N: Revealed type is "Tuple[builtins.str, builtins.int, builtins.str, builtins.int]" def f() -> Tuple[str, ...]: return ('', ) -reveal_type(f() * 2) # N: Revealed type is "builtins.tuple[builtins.str*]" +reveal_type(f() * 2) # N: Revealed type is "builtins.tuple[builtins.str*, ...]" [builtins fixtures/tuple.pyi] [case testMultiplyTupleByIntegerLiteralReverse] @@ -1494,7 +1494,7 @@ t3 = 2 * ('', 1) reveal_type(t3) # N: Revealed type is "Tuple[builtins.str, builtins.int, builtins.str, builtins.int]" def f() -> Tuple[str, ...]: return ('', ) -reveal_type(2 * f()) # N: Revealed type is "builtins.tuple[builtins.str*]" +reveal_type(2 * f()) # N: Revealed type is "builtins.tuple[builtins.str*, ...]" [builtins fixtures/tuple.pyi] [case testSingleUndefinedTypeAndTuple] diff --git a/test-data/unit/check-type-aliases.test b/test-data/unit/check-type-aliases.test index a697c32d7c49..eb6c71e8f226 100644 --- a/test-data/unit/check-type-aliases.test +++ b/test-data/unit/check-type-aliases.test @@ -312,7 +312,7 @@ T = Tuple c: C t: T reveal_type(c) # N: Revealed type is "def (*Any, **Any) -> Any" -reveal_type(t) # N: Revealed type is "builtins.tuple[Any]" +reveal_type(t) # N: Revealed type is "builtins.tuple[Any, ...]" bad: C[int] # E: Bad number of arguments for type alias, expected: 0, given: 1 also_bad: T[int] # E: Bad number of arguments for type alias, expected: 0, given: 1 [builtins fixtures/tuple.pyi] diff --git a/test-data/unit/merge.test b/test-data/unit/merge.test index 836ad87857f8..3eb41c2303dd 100644 --- a/test-data/unit/merge.test +++ b/test-data/unit/merge.test @@ -665,7 +665,7 @@ TypeInfo<0>( Names()) TypeInfo<2>( Name(target.N) - Bases(builtins.tuple[target.A<0>]<3>) + Bases(builtins.tuple[target.A<0>, ...]<3>) Mro(target.N<2>, builtins.tuple<3>, typing.Sequence<4>, typing.Iterable<5>, builtins.object<1>) Names( _NT<6> @@ -688,7 +688,7 @@ TypeInfo<0>( Names()) TypeInfo<2>( Name(target.N) - Bases(builtins.tuple[target.A<0>]<3>) + Bases(builtins.tuple[target.A<0>, ...]<3>) Mro(target.N<2>, builtins.tuple<3>, typing.Sequence<4>, typing.Iterable<5>, builtins.object<1>) Names( _NT<6> diff --git a/test-data/unit/pep561.test b/test-data/unit/pep561.test index 839ca110b94c..364414b202e1 100644 --- a/test-data/unit/pep561.test +++ b/test-data/unit/pep561.test @@ -18,7 +18,7 @@ from typedpkg import dne a = ex(['']) reveal_type(a) [out] -testTypedPkgSimple.py:5: note: Revealed type is "builtins.tuple[builtins.str]" +testTypedPkgSimple.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]" [case testTypedPkgSimplePackageSearchPath] # pkgs: typedpkg @@ -89,7 +89,7 @@ from typedpkg import dne a = ex(['']) reveal_type(a) [out] -testTypedPkgSimple_python2.py:5: note: Revealed type is "builtins.tuple[builtins.str]" +testTypedPkgSimple_python2.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]" [case testTypedPkgSimpleEgg] # pkgs: typedpkg; no-pip @@ -98,7 +98,7 @@ from typedpkg import dne a = ex(['']) reveal_type(a) [out] -testTypedPkgSimpleEgg.py:5: note: Revealed type is "builtins.tuple[builtins.str]" +testTypedPkgSimpleEgg.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]" [case testTypedPkgSimpleEditable] # pkgs: typedpkg; editable @@ -107,7 +107,7 @@ from typedpkg import dne a = ex(['']) reveal_type(a) [out] -testTypedPkgSimpleEditable.py:5: note: Revealed type is "builtins.tuple[builtins.str]" +testTypedPkgSimpleEditable.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]" [case testTypedPkgSimpleEditableEgg] # pkgs: typedpkg; editable; no-pip @@ -116,7 +116,7 @@ from typedpkg import dne a = ex(['']) reveal_type(a) [out] -testTypedPkgSimpleEditableEgg.py:5: note: Revealed type is "builtins.tuple[builtins.str]" +testTypedPkgSimpleEditableEgg.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]" [case testTypedPkgNamespaceImportFrom] # pkgs: typedpkg, typedpkg_ns_a diff --git a/test-data/unit/pythoneval.test b/test-data/unit/pythoneval.test index 90588a86d8bf..9bf511e1aba3 100644 --- a/test-data/unit/pythoneval.test +++ b/test-data/unit/pythoneval.test @@ -1411,7 +1411,7 @@ accepts_named_tuple(1) accepts_named_tuple((1, 2)) [out] _testNamedTupleTypeInheritanceSpecialCase.py:8: note: Revealed type is "collections.OrderedDict[builtins.str, Any]" -_testNamedTupleTypeInheritanceSpecialCase.py:9: note: Revealed type is "builtins.tuple[builtins.str]" +_testNamedTupleTypeInheritanceSpecialCase.py:9: note: Revealed type is "builtins.tuple[builtins.str, ...]" _testNamedTupleTypeInheritanceSpecialCase.py:10: note: Revealed type is "builtins.dict[builtins.str, Any]" _testNamedTupleTypeInheritanceSpecialCase.py:17: error: Argument 1 to "accepts_named_tuple" has incompatible type "int"; expected "NamedTuple" _testNamedTupleTypeInheritanceSpecialCase.py:18: error: Argument 1 to "accepts_named_tuple" has incompatible type "Tuple[int, int]"; expected "NamedTuple" diff --git a/test-data/unit/semanal-classes.test b/test-data/unit/semanal-classes.test index 3d62fed2b5e7..082a3fe69050 100644 --- a/test-data/unit/semanal-classes.test +++ b/test-data/unit/semanal-classes.test @@ -582,7 +582,7 @@ MypyFile:1( TupleType( Tuple[builtins.int, builtins.str]) BaseType( - builtins.tuple[builtins.object]) + builtins.tuple[builtins.object, ...]) PassStmt:2())) [case testBaseClassFromIgnoredModule] diff --git a/test-data/unit/semanal-python2.test b/test-data/unit/semanal-python2.test index 97264a5dc503..8bb0f5cf5d9c 100644 --- a/test-data/unit/semanal-python2.test +++ b/test-data/unit/semanal-python2.test @@ -45,7 +45,7 @@ MypyFile:1( ExpressionStmt:2( CastExpr:2( TupleExpr:2() - builtins.tuple[builtins.int]))) + builtins.tuple[builtins.int, ...]))) [case testTupleArgList_python2] def f(x, (y, z)): diff --git a/test-data/unit/semanal-types.test b/test-data/unit/semanal-types.test index 772de61b5900..1a2eca64a9f2 100644 --- a/test-data/unit/semanal-types.test +++ b/test-data/unit/semanal-types.test @@ -679,7 +679,7 @@ MypyFile:1( AssignmentStmt:2( NameExpr(t [__main__.t]) NameExpr(None [builtins.None]) - builtins.tuple[Any]) + builtins.tuple[Any, ...]) AssignmentStmt:3( NameExpr(t1 [__main__.t1]) NameExpr(None [builtins.None]) @@ -699,7 +699,7 @@ MypyFile:1( AssignmentStmt:2( NameExpr(t [__main__.t]) NameExpr(None [builtins.None]) - builtins.tuple[builtins.int])) + builtins.tuple[builtins.int, ...])) [case testInvalidTupleType] from typing import Tuple