Skip to content

Make tuple generic in most stubs #3767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test-data/unit/check-isinstance.test
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
9 changes: 5 additions & 4 deletions test-data/unit/fixtures/async_await.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
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
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
Expand Down
4 changes: 3 additions & 1 deletion test-data/unit/fixtures/bool.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/fixtures/dict.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test-data/unit/fixtures/exception.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions test-data/unit/fixtures/fine_grained.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# enough to handle them.

import types
from typing import TypeVar, Generic

T = TypeVar('T')

class Any: pass

Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is still one more tuple not fixed in isinstancelist.pyi.

class list(Generic[T]): pass
5 changes: 4 additions & 1 deletion test-data/unit/fixtures/float.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from typing import Generic, TypeVar
T = TypeVar('T')

Any = 0

class object:
Expand All @@ -12,7 +15,7 @@ class str:

class bytes: pass

class tuple: pass
class tuple(Generic[T]): pass
class function: pass

class ellipsis: pass
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/fixtures/floatdict.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class str:

class bytes: pass

class tuple: pass
class tuple(Generic[T]): pass
class function: pass

class ellipsis: pass
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/fixtures/for.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions test-data/unit/fixtures/isinstancelist.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
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

class type:
def __init__(self, x) -> None: pass

class tuple: pass
class function: pass
class ellipsis: pass

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/fixtures/module.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/fixtures/module_all.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test-data/unit/fixtures/module_all_python2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion test-data/unit/fixtures/primitives.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion test-data/unit/fixtures/set.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test-data/unit/fixtures/slice.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/fixtures/type.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions test-data/unit/fixtures/union.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# 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

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
Expand Down