Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Make tests compatible with change (WIP)
  • Loading branch information
seddonym committed Dec 18, 2023
commit 4c37dac8f2725a2377e3454c9bcb1b6fb729203a
2 changes: 2 additions & 0 deletions test-data/unit/fine-grained.test
Original file line number Diff line number Diff line change
Expand Up @@ -5390,6 +5390,7 @@ from enum import Enum

class C(Enum):
X = 0
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-medium.pyi]
[out]
==
Expand Down Expand Up @@ -5486,6 +5487,7 @@ C = Enum('C', 'X Y')
from enum import Enum

C = Enum('C', 'X')
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-medium.pyi]
[out]
==
Expand Down
3 changes: 3 additions & 0 deletions test-data/unit/fixtures/async_await.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import typing
from typing_extensions import override

T = typing.TypeVar('T')
U = typing.TypeVar('U')
class list(typing.Sequence[T]):
@override
def __iter__(self) -> typing.Iterator[T]: ...
@override
def __getitem__(self, i: int) -> T: ...
def __contains__(self, item: object) -> bool: ...

Expand Down
5 changes: 5 additions & 0 deletions test-data/unit/fixtures/dataclasses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from typing import (
Generic, Iterator, Iterable, Mapping, Optional, Sequence, Tuple,
TypeVar, Union, overload,
)
from typing_extensions import override

_T = TypeVar('_T')
_U = TypeVar('_U')
Expand All @@ -29,8 +30,10 @@ class dict(Mapping[KT, VT]):
def __init__(self, **kwargs: VT) -> None: pass
@overload
def __init__(self, arg: Iterable[Tuple[KT, VT]], **kwargs: VT) -> None: pass
@override
def __getitem__(self, key: KT) -> VT: pass
def __setitem__(self, k: KT, v: VT) -> None: pass
@override
def __iter__(self) -> Iterator[KT]: pass
def __contains__(self, item: object) -> int: pass
def update(self, a: Mapping[KT, VT]) -> None: pass
Expand All @@ -42,7 +45,9 @@ class dict(Mapping[KT, VT]):

class list(Generic[_T], Sequence[_T]):
def __contains__(self, item: object) -> int: pass
@override
def __getitem__(self, key: int) -> _T: pass
@override
def __iter__(self) -> Iterator[_T]: pass

class function: pass
Expand Down
5 changes: 5 additions & 0 deletions test-data/unit/fixtures/dict.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import _typeshed
from typing import (
TypeVar, Generic, Iterable, Iterator, Mapping, Tuple, overload, Optional, Union, Sequence
)
from typing_extensions import override

T = TypeVar('T')
KT = TypeVar('KT')
Expand All @@ -23,8 +24,10 @@ class dict(Mapping[KT, VT]):
def __init__(self, **kwargs: VT) -> None: pass
@overload
def __init__(self, arg: Iterable[Tuple[KT, VT]], **kwargs: VT) -> None: pass
@override
def __getitem__(self, key: KT) -> VT: pass
def __setitem__(self, k: KT, v: VT) -> None: pass
@override
def __iter__(self) -> Iterator[KT]: pass
def __contains__(self, item: object) -> int: pass
def update(self, a: SupportsKeysAndGetItem[KT, VT]) -> None: pass
Expand All @@ -46,7 +49,9 @@ class str: pass # for keyword argument key type
class bytes: pass

class list(Sequence[T]): # needed by some test cases
@override
def __getitem__(self, x: int) -> T: pass
@override
def __iter__(self) -> Iterator[T]: pass
def __mul__(self, x: int) -> list[T]: pass
def __contains__(self, item: object) -> bool: pass
Expand Down
3 changes: 3 additions & 0 deletions test-data/unit/fixtures/list.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Builtins stub used in list-related test cases.

from typing import TypeVar, Generic, Iterable, Iterator, Sequence, overload
from typing_extensions import override

T = TypeVar('T')

Expand All @@ -15,11 +16,13 @@ class list(Sequence[T]):
def __init__(self) -> None: pass
@overload
def __init__(self, x: Iterable[T]) -> None: pass
@override
def __iter__(self) -> Iterator[T]: pass
def __len__(self) -> int: pass
def __contains__(self, item: object) -> bool: pass
def __add__(self, x: list[T]) -> list[T]: pass
def __mul__(self, x: int) -> list[T]: pass
@override
def __getitem__(self, x: int) -> T: pass
def __setitem__(self, x: int, v: T) -> None: pass
def append(self, x: T) -> None: pass
Expand Down
3 changes: 3 additions & 0 deletions test-data/unit/fixtures/plugin_attrs.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Builtins stub used to support attrs plugin tests.
from typing import Union, overload, Generic, Sequence, TypeVar, Type, Iterable, Iterator
from typing_extensions import override

class object:
def __init__(self) -> None: pass
Expand Down Expand Up @@ -31,6 +32,8 @@ T = TypeVar("T")
Tco = TypeVar('Tco', covariant=True)
class tuple(Sequence[Tco], Generic[Tco]):
def __new__(cls: Type[T], iterable: Iterable[Tco] = ...) -> T: ...
@override
def __iter__(self) -> Iterator[Tco]: pass
def __contains__(self, item: object) -> bool: pass
@override
def __getitem__(self, x: int) -> Tco: pass
16 changes: 16 additions & 0 deletions test-data/unit/fixtures/primitives.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# builtins stub with non-generic primitive types
import _typeshed
from typing import Generic, TypeVar, Sequence, Iterator, Mapping, Iterable, Tuple, Union
from typing_extensions import override

T = TypeVar('T')
V = TypeVar('V')
Expand All @@ -27,35 +28,48 @@ class complex:
class bool(int): pass
class str(Sequence[str]):
def __add__(self, s: str) -> str: pass
@override
def __iter__(self) -> Iterator[str]: pass
def __contains__(self, other: object) -> bool: pass
@override
def __getitem__(self, item: int) -> str: pass
def format(self, *args: object, **kwargs: object) -> str: pass
class bytes(Sequence[int]):
@override
def __iter__(self) -> Iterator[int]: pass
def __contains__(self, other: object) -> bool: pass
@override
def __getitem__(self, item: int) -> int: pass
class bytearray(Sequence[int]):
def __init__(self, x: bytes) -> None: pass
@override
def __iter__(self) -> Iterator[int]: pass
def __contains__(self, other: object) -> bool: pass
@override
def __getitem__(self, item: int) -> int: pass
class memoryview(Sequence[int]):
def __init__(self, x: bytes) -> None: pass
@override
def __iter__(self) -> Iterator[int]: pass
def __contains__(self, other: object) -> bool: pass
@override
def __getitem__(self, item: int) -> int: pass
class tuple(Generic[T]):
def __contains__(self, other: object) -> bool: pass
class list(Sequence[T]):
@override
def __iter__(self) -> Iterator[T]: pass
def __contains__(self, other: object) -> bool: pass
@override
def __getitem__(self, item: int) -> T: pass
class dict(Mapping[T, V]):
@override
def __iter__(self) -> Iterator[T]: pass
class set(Iterable[T]):
@override
def __iter__(self) -> Iterator[T]: pass
class frozenset(Iterable[T]):
@override
def __iter__(self) -> Iterator[T]: pass
class function: pass
class ellipsis: pass
Expand All @@ -64,7 +78,9 @@ class range(Sequence[int]):
def __init__(self, __x: int, __y: int = ..., __z: int = ...) -> None: pass
def count(self, value: int) -> int: pass
def index(self, value: int) -> int: pass
@override
def __getitem__(self, i: int) -> int: pass
@override
def __iter__(self) -> Iterator[int]: pass
def __contains__(self, other: object) -> bool: pass

Expand Down
2 changes: 2 additions & 0 deletions test-data/unit/fixtures/set.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Builtins stub used in set-related test cases.

from typing import TypeVar, Generic, Iterator, Iterable, Set
from typing_extensions import override

T = TypeVar('T')

Expand All @@ -19,6 +20,7 @@ class ellipsis: pass

class set(Iterable[T], Generic[T]):
def __init__(self, iterable: Iterable[T] = ...) -> None: ...
@override
def __iter__(self) -> Iterator[T]: pass
def __contains__(self, item: object) -> bool: pass
def __ior__(self, x: Set[T]) -> None: pass
Expand Down
8 changes: 7 additions & 1 deletion test-data/unit/fixtures/tuple.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import _typeshed
from typing import Iterable, Iterator, TypeVar, Generic, Sequence, Optional, overload, Tuple, Type

from typing_extensions import override
T = TypeVar("T")
Tco = TypeVar('Tco', covariant=True)

Expand All @@ -14,11 +14,14 @@ class type:
def __call__(self, *a: object) -> object: pass
class tuple(Sequence[Tco], Generic[Tco]):
def __new__(cls: Type[T], iterable: Iterable[Tco] = ...) -> T: ...
@override
def __iter__(self) -> Iterator[Tco]: pass
def __contains__(self, item: object) -> bool: pass
@overload
@override
def __getitem__(self, x: int) -> Tco: pass
@overload
@override
def __getitem__(self, x: slice) -> Tuple[Tco, ...]: ...
def __mul__(self, n: int) -> Tuple[Tco, ...]: pass
def __rmul__(self, n: int) -> Tuple[Tco, ...]: pass
Expand All @@ -41,10 +44,13 @@ class bytearray: pass

class list(Sequence[T], Generic[T]):
@overload
@override
def __getitem__(self, i: int) -> T: ...
@overload
@override
def __getitem__(self, s: slice) -> list[T]: ...
def __contains__(self, item: object) -> bool: ...
@override
def __iter__(self) -> Iterator[T]: ...

def isinstance(x: object, t: type) -> bool: pass
Expand Down
3 changes: 3 additions & 0 deletions test-data/unit/fixtures/typing-medium.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Many of the definitions have special handling in the type checker, so they
# can just be initialized to anything.

from typing_extensions import override

cast = 0
overload = 0
Any = 0
Expand Down Expand Up @@ -49,6 +51,7 @@ class Iterator(Iterable[T_co], Protocol):
def __next__(self) -> T_co: pass

class Generator(Iterator[T], Generic[T, U, V]):
@override
def __iter__(self) -> 'Generator[T, U, V]': pass

class Sequence(Iterable[T_co]):
Expand Down
2 changes: 2 additions & 0 deletions test-data/unit/fixtures/typing-typeddict.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# can just be initialized to anything.

from abc import ABCMeta
from typing_extensions import override

cast = 0
assert_type = 0
Expand Down Expand Up @@ -63,6 +64,7 @@ class Mapping(Iterable[T], Generic[T, T_co], metaclass=ABCMeta):
class _TypedDict(Mapping[str, object]):
# Needed to make this class non-abstract. It is explicitly declared abstract in
# typeshed, but we don't want to import abc here, as it would slow down the tests.
@override
def __iter__(self) -> Iterator[str]: ...
def copy(self: T) -> T: ...
# Using NoReturn so that only calls using the plugin hook can go through.
Expand Down