File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -993,3 +993,28 @@ x_bad: A[bytes] # E: Value of type variable "S" of "A" cannot be "bytes"
993
993
B = List[C[U]]
994
994
y: B[int]
995
995
y_bad: B[str] # E: Type argument "str" of "B" must be a subtype of "int"
996
+
997
+ [case testTupleWithDifferentArgsPy38]
998
+ # flags: --python-version 3.8
999
+ NotYet1 = tuple[float] # E: "tuple" is not subscriptable
1000
+ NotYet2 = tuple[float, float] # E: "tuple" is not subscriptable
1001
+ [builtins fixtures/tuple.pyi]
1002
+
1003
+ [case testTupleWithDifferentArgsStub]
1004
+ # https://github.com/python/mypy/issues/11098
1005
+ import tup
1006
+
1007
+ [file tup.pyi]
1008
+ Correct1 = str | tuple[float, float, str]
1009
+ Correct2 = tuple[float] | str
1010
+ Correct3 = tuple[float, ...] | str
1011
+
1012
+ RHSAlias1: type = tuple[int, int]
1013
+ RHSAlias2: type = tuple[int]
1014
+ RHSAlias3: type = tuple[int, ...]
1015
+
1016
+ # Wrong:
1017
+
1018
+ WrongTypeElement = str | tuple[float, 1] # E: Invalid type: try using Literal[1] instead?
1019
+ WrongEllipsis = str | tuple[float, float, ...] # E: Unexpected "..."
1020
+ [builtins fixtures/tuple.pyi]
Original file line number Diff line number Diff line change @@ -1816,3 +1816,21 @@ def foo(k: str) -> TD:
1816
1816
return x.get(k, {})
1817
1817
[out]
1818
1818
_testTypedDictUnionGetFull.py:11: note: Revealed type is "TypedDict('_testTypedDictUnionGetFull.TD', {'x'?: builtins.int, 'y'?: builtins.int})"
1819
+
1820
+ [case testTupleWithDifferentArgsPy310]
1821
+ # https://github.com/python/mypy/issues/11098
1822
+ # flags: --python-version 3.10
1823
+ Correct1 = str | tuple[float, float, str]
1824
+ Correct2 = tuple[float] | str
1825
+ Correct3 = tuple[float, ...] | str
1826
+
1827
+ RHSAlias1: type = tuple[int, int]
1828
+ RHSAlias2: type = tuple[int]
1829
+ RHSAlias3: type = tuple[int, ...]
1830
+
1831
+ # Wrong:
1832
+ WrongTypeElement = str | tuple[float, 1]
1833
+ WrongEllipsis = tuple[float, float, ...] | str
1834
+ [out]
1835
+ _testTupleWithDifferentArgsPy310.py:12: error: Invalid type: try using Literal[1] instead?
1836
+ _testTupleWithDifferentArgsPy310.py:13: error: Unexpected "..."
You can’t perform that action at this time.
0 commit comments