Skip to content
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

Fix tests stubs #140

Merged
merged 2 commits into from
Apr 11, 2024
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 asyncstdlib/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __lt__(self: LT, other: LT) -> bool:


class SupportsAdd(Protocol):
def __add__(self: ADD, other: ADD) -> ADD:
def __add__(self: ADD, other: ADD, /) -> ADD:
raise NotImplementedError


Expand Down
22 changes: 10 additions & 12 deletions asyncstdlib/itertools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -63,53 +63,51 @@ class chain(AsyncIterator[T]):
async def aclose(self) -> None: ...

def compress(data: AnyIterable[T], selectors: AnyIterable[Any]) -> AsyncIterator[T]: ...
async def dropwhile(
def dropwhile(
predicate: Callable[[T], Any], iterable: AnyIterable[T]
) -> AsyncIterator[T]: ...
async def filterfalse(
def filterfalse(
predicate: Callable[[T], Any] | None, iterable: AnyIterable[T]
) -> AsyncIterator[T]: ...
@overload
async def islice(
iterable: AnyIterable[T], start: int | None, /
) -> AsyncIterator[T]: ...
def islice(iterable: AnyIterable[T], start: int | None, /) -> AsyncIterator[T]: ...
@overload
async def islice(
def islice(
iterable: AnyIterable[T],
start: int | None,
stop: int | None,
step: int | None = None,
/,
) -> AsyncIterator[T]: ...
@overload
async def starmap(
def starmap(
function: Callable[[T1], T] | Callable[[T1], Awaitable[T]],
iterable: AnyIterable[tuple[T1]],
) -> AsyncIterator[T]: ...
@overload
async def starmap(
def starmap(
function: Callable[[T1, T2], T] | Callable[[T1, T2], Awaitable[T]],
iterable: AnyIterable[tuple[T1, T2]],
) -> AsyncIterator[T]: ...
@overload
async def starmap(
def starmap(
function: Callable[[T1, T2, T3], T] | Callable[[T1, T2, T3], Awaitable[T]],
iterable: AnyIterable[tuple[T1, T2, T3]],
) -> AsyncIterator[T]: ...
@overload
async def starmap(
def starmap(
function: Callable[[T1, T2, T3, T4], T] | Callable[[T1, T2, T3, T4], Awaitable[T]],
iterable: AnyIterable[tuple[T1, T2, T3, T4]],
) -> AsyncIterator[T]: ...
@overload
async def starmap(
def starmap(
function: (
Callable[[T1, T2, T3, T4, T5], T] | Callable[[T1, T2, T3, T4, T5], Awaitable[T]]
),
iterable: AnyIterable[tuple[T1, T2, T3, T4, T5]],
) -> AsyncIterator[T]: ...
@overload
async def starmap(
def starmap(
function: Callable[..., T] | Callable[..., Awaitable[T]],
iterable: AnyIterable[Iterable[Any]],
) -> AsyncIterator[T]: ...
Expand Down
71 changes: 71 additions & 0 deletions typetests/test_itertools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from typing import AsyncIterator
Fixed Show fixed Hide fixed
isra17 marked this conversation as resolved.
Show resolved Hide resolved
from asyncstdlib import itertools
from typing_extensions import assert_type


async def test_cycle() -> None:
async for x in itertools.cycle([1]):
assert_type(x, int)


async def test_accumulate() -> None:
async for x in itertools.accumulate([1]):
assert_type(x, int)


async def test_batched() -> None:
async for x in itertools.batched([1], 1):
assert_type(x, "tuple[int]")


async def test_chain() -> None:
async for x in itertools.chain([1]):
assert_type(x, int)


async def test_compress() -> None:
async for x in itertools.compress([1], [1]):
assert_type(x, int)


async def test_dropwhile() -> None:
async for x in itertools.dropwhile(lambda x: True, [1]):
assert_type(x, int)


async def test_filterfalse() -> None:
async for x in itertools.filterfalse(lambda x: True, [1]):
assert_type(x, int)


async def test_starmap() -> None:
def f(x: str) -> int:
return int(x)

async for x in itertools.starmap(f, [("1",)]):
assert_type(x, int)


async def test_takewhile() -> None:
async for x in itertools.takewhile(lambda x: True, [1]):
assert_type(x, int)


async def test_tee() -> None:
async for x in itertools.tee([1])[0]:
assert_type(x, int)


async def test_pairwise() -> None:
async for x in itertools.pairwise([1]):
assert_type(x, "tuple[int, int]")


async def test_zip_longest() -> None:
async for x in itertools.zip_longest([1]):
assert_type(x, "tuple[int]")


async def test_groupby() -> None:
async for x in itertools.groupby([1]):
assert_type(x, "tuple[int, AsyncIterator[int]]")