diff --git a/test-data/unit/check-isinstance.test b/test-data/unit/check-isinstance.test index 67be4c13ecba..cb375dfaa484 100644 --- a/test-data/unit/check-isinstance.test +++ b/test-data/unit/check-isinstance.test @@ -1749,7 +1749,7 @@ if isinstance(x): # E: Too few arguments for "isinstance" [case testIsInstanceTooManyArgs] isinstance(1, 1, 1) # E: Too many arguments for "isinstance" \ - # E: Argument 2 to "isinstance" has incompatible type "int"; expected "Union[type, tuple]" + # E: Argument 2 to "isinstance" has incompatible type "int"; expected "Union[type, Tuple[Any, ...]]" x: object if isinstance(x, str, 1): # E: Too many arguments for "isinstance" reveal_type(x) # E: Revealed type is 'builtins.object' diff --git a/test-data/unit/fixtures/async_await.pyi b/test-data/unit/fixtures/async_await.pyi index 42c1b53eb4bd..dcd25dea93cd 100644 --- a/test-data/unit/fixtures/async_await.pyi +++ b/test-data/unit/fixtures/async_await.pyi @@ -1,7 +1,8 @@ import typing T = typing.TypeVar('T') -class list(typing.Generic[T], typing.Sequence[T]): pass +U = typing.TypeVar('U') +class list(typing.Sequence[T]): pass class object: def __init__(self): pass @@ -9,9 +10,9 @@ class type: pass class function: pass class int: pass class str: pass -class dict: pass -class set: pass -class tuple: pass +class dict(typing.Generic[T, U]): pass +class set(typing.Generic[T]): pass +class tuple(typing.Generic[T]): pass class BaseException: pass class StopIteration(BaseException): pass class StopAsyncIteration(BaseException): pass diff --git a/test-data/unit/fixtures/bool.pyi b/test-data/unit/fixtures/bool.pyi index c4b4f3080f15..a1d1b9c1fdf5 100644 --- a/test-data/unit/fixtures/bool.pyi +++ b/test-data/unit/fixtures/bool.pyi @@ -1,10 +1,12 @@ # builtins stub used in boolean-related test cases. +from typing import Generic, TypeVar +T = TypeVar('T') class object: def __init__(self) -> None: pass class type: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class bool: pass class int: pass diff --git a/test-data/unit/fixtures/dict.pyi b/test-data/unit/fixtures/dict.pyi index 4182afb0eecd..a271315e4dde 100644 --- a/test-data/unit/fixtures/dict.pyi +++ b/test-data/unit/fixtures/dict.pyi @@ -35,7 +35,7 @@ class list(Iterable[T], Generic[T]): # needed by some test cases def __iter__(self) -> Iterator[T]: pass def __mul__(self, x: int) -> list[T]: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class float: pass class bool: pass diff --git a/test-data/unit/fixtures/exception.pyi b/test-data/unit/fixtures/exception.pyi index 5a2482dc1f87..999a73739364 100644 --- a/test-data/unit/fixtures/exception.pyi +++ b/test-data/unit/fixtures/exception.pyi @@ -1,9 +1,11 @@ +from typing import Generic, TypeVar +T = TypeVar('T') class object: def __init__(self): pass class type: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class int: pass class str: pass diff --git a/test-data/unit/fixtures/fine_grained.pyi b/test-data/unit/fixtures/fine_grained.pyi index 83429cd38314..b2e104ccfceb 100644 --- a/test-data/unit/fixtures/fine_grained.pyi +++ b/test-data/unit/fixtures/fine_grained.pyi @@ -4,6 +4,9 @@ # enough to handle them. import types +from typing import TypeVar, Generic + +T = TypeVar('T') class Any: pass @@ -20,7 +23,7 @@ class str: class float: pass class bytes: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class ellipsis: pass -class list: pass +class list(Generic[T]): pass diff --git a/test-data/unit/fixtures/float.pyi b/test-data/unit/fixtures/float.pyi index 38bdc08a03c5..1126d6158c6a 100644 --- a/test-data/unit/fixtures/float.pyi +++ b/test-data/unit/fixtures/float.pyi @@ -1,3 +1,6 @@ +from typing import Generic, TypeVar +T = TypeVar('T') + Any = 0 class object: @@ -12,7 +15,7 @@ class str: class bytes: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class ellipsis: pass diff --git a/test-data/unit/fixtures/floatdict.pyi b/test-data/unit/fixtures/floatdict.pyi index 9a34f8d369a0..54850d7f6e27 100644 --- a/test-data/unit/fixtures/floatdict.pyi +++ b/test-data/unit/fixtures/floatdict.pyi @@ -18,7 +18,7 @@ class str: class bytes: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class ellipsis: pass diff --git a/test-data/unit/fixtures/for.pyi b/test-data/unit/fixtures/for.pyi index 47628062f118..8b8ce1c3a500 100644 --- a/test-data/unit/fixtures/for.pyi +++ b/test-data/unit/fixtures/for.pyi @@ -9,7 +9,7 @@ class object: def __init__(self) -> None: pass class type: pass -class tuple: pass +class tuple(Generic[t]): pass class function: pass class bool: pass class int: pass # for convenience diff --git a/test-data/unit/fixtures/isinstancelist.pyi b/test-data/unit/fixtures/isinstancelist.pyi index 5ee49b86f7fd..930d309aa3db 100644 --- a/test-data/unit/fixtures/isinstancelist.pyi +++ b/test-data/unit/fixtures/isinstancelist.pyi @@ -1,4 +1,4 @@ -from typing import Iterable, Iterator, TypeVar, List, Mapping, overload, Tuple, Set, Union +from typing import Iterable, Iterator, TypeVar, List, Mapping, overload, Tuple, Set, Union, Generic class object: def __init__(self) -> None: pass @@ -6,7 +6,6 @@ class object: class type: def __init__(self, x) -> None: pass -class tuple: pass class function: pass class ellipsis: pass @@ -24,6 +23,8 @@ T = TypeVar('T') KT = TypeVar('KT') VT = TypeVar('VT') +class tuple(Generic[T]): pass + class list(Iterable[T]): def __iter__(self) -> Iterator[T]: pass def __mul__(self, x: int) -> list[T]: pass diff --git a/test-data/unit/fixtures/module.pyi b/test-data/unit/fixtures/module.pyi index 44a4dfe0c277..ac1d3688ed12 100644 --- a/test-data/unit/fixtures/module.pyi +++ b/test-data/unit/fixtures/module.pyi @@ -13,7 +13,7 @@ class function: pass class int: pass class str: pass class bool: pass -class tuple: pass +class tuple(Generic[T]): pass class dict(Generic[T, S]): pass class ellipsis: pass diff --git a/test-data/unit/fixtures/module_all.pyi b/test-data/unit/fixtures/module_all.pyi index 2ab6bc66f6f0..87959fefbff5 100644 --- a/test-data/unit/fixtures/module_all.pyi +++ b/test-data/unit/fixtures/module_all.pyi @@ -14,5 +14,5 @@ class list(Generic[_T], Sequence[_T]): def append(self, x: _T): pass def extend(self, x: Sequence[_T]): pass def __add__(self, rhs: Sequence[_T]) -> list[_T]: pass -class tuple: pass +class tuple(Generic[_T]): pass class ellipsis: pass diff --git a/test-data/unit/fixtures/module_all_python2.pyi b/test-data/unit/fixtures/module_all_python2.pyi index 5a48e60c512d..989333c5f41a 100644 --- a/test-data/unit/fixtures/module_all_python2.pyi +++ b/test-data/unit/fixtures/module_all_python2.pyi @@ -12,4 +12,4 @@ class list(Generic[_T], Sequence[_T]): def append(self, x: _T): pass def extend(self, x: Sequence[_T]): pass def __add__(self, rhs: Sequence[_T]) -> list[_T]: pass -class tuple: pass +class tuple(Generic[_T]): pass diff --git a/test-data/unit/fixtures/primitives.pyi b/test-data/unit/fixtures/primitives.pyi index 4b5611b0bace..6cedba37c6c1 100644 --- a/test-data/unit/fixtures/primitives.pyi +++ b/test-data/unit/fixtures/primitives.pyi @@ -1,4 +1,6 @@ # builtins stub with non-generic primitive types +from typing import Generic, TypeVar +T = TypeVar('T') class object: def __init__(self) -> None: pass @@ -17,5 +19,5 @@ class str: def format(self, *args) -> str: pass class bytes: pass class bytearray: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass diff --git a/test-data/unit/fixtures/set.pyi b/test-data/unit/fixtures/set.pyi index cb8bbcf841e7..79d53e832291 100644 --- a/test-data/unit/fixtures/set.pyi +++ b/test-data/unit/fixtures/set.pyi @@ -8,7 +8,7 @@ class object: def __init__(self) -> None: pass class type: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class int: pass diff --git a/test-data/unit/fixtures/slice.pyi b/test-data/unit/fixtures/slice.pyi index c01ffbb1ca4c..47c1999aecb7 100644 --- a/test-data/unit/fixtures/slice.pyi +++ b/test-data/unit/fixtures/slice.pyi @@ -1,10 +1,12 @@ # Builtins stub used in slicing test cases. +from typing import Generic, TypeVar +T = TypeVar('T') class object: def __init__(self): pass class type: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class int: pass diff --git a/test-data/unit/fixtures/type.pyi b/test-data/unit/fixtures/type.pyi index 7600021a30ea..4a2dcac1ab4b 100644 --- a/test-data/unit/fixtures/type.pyi +++ b/test-data/unit/fixtures/type.pyi @@ -13,7 +13,7 @@ class list(Generic[T]): pass class type: def mro(self) -> List['type']: pass -class tuple: pass +class tuple(Generic[T]): pass class function: pass class bool: pass class int: pass diff --git a/test-data/unit/fixtures/union.pyi b/test-data/unit/fixtures/union.pyi index 78a41f9272e6..489e3ddb6ef9 100644 --- a/test-data/unit/fixtures/union.pyi +++ b/test-data/unit/fixtures/union.pyi @@ -1,7 +1,8 @@ # Builtins stub used in tuple-related test cases. from isinstance import isinstance -from typing import Iterable, TypeVar +from typing import Iterable, TypeVar, Generic +T = TypeVar('T') class object: def __init__(self): pass @@ -9,9 +10,7 @@ class object: class type: pass class function: pass -# Current tuple types get special treatment in the type checker, thus there -# is no need for type arguments here. -class tuple: pass +class tuple(Generic[T]): pass # We need int for indexing tuples. class int: pass