Skip to content

Remove redundant inheritances from Iterator in itertools #12816

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 1 commit into from
Oct 18, 2024
Merged
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
38 changes: 19 additions & 19 deletions stdlib/itertools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _Predicate: TypeAlias = Callable[[_T], object]

# Technically count can take anything that implements a number protocol and has an add method
# but we can't enforce the add method
class count(Iterator[_N]):
class count(Generic[_N]):
@overload
def __new__(cls) -> count[int]: ...
@overload
Expand All @@ -38,12 +38,12 @@ class count(Iterator[_N]):
def __next__(self) -> _N: ...
def __iter__(self) -> Self: ...

class cycle(Iterator[_T]):
class cycle(Generic[_T]):
def __init__(self, iterable: Iterable[_T], /) -> None: ...
def __next__(self) -> _T: ...
def __iter__(self) -> Self: ...

class repeat(Iterator[_T]):
class repeat(Generic[_T]):
@overload
def __init__(self, object: _T) -> None: ...
@overload
Expand All @@ -52,15 +52,15 @@ class repeat(Iterator[_T]):
def __iter__(self) -> Self: ...
def __length_hint__(self) -> int: ...

class accumulate(Iterator[_T]):
class accumulate(Generic[_T]):
@overload
def __init__(self, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> None: ...
@overload
def __init__(self, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = ...) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

class chain(Iterator[_T]):
class chain(Generic[_T]):
def __init__(self, *iterables: Iterable[_T]) -> None: ...
def __next__(self) -> _T: ...
def __iter__(self) -> Self: ...
Expand All @@ -70,50 +70,50 @@ class chain(Iterator[_T]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

class compress(Iterator[_T]):
class compress(Generic[_T]):
def __init__(self, data: Iterable[_T], selectors: Iterable[Any]) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

class dropwhile(Iterator[_T]):
class dropwhile(Generic[_T]):
def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

class filterfalse(Iterator[_T]):
class filterfalse(Generic[_T]):
def __init__(self, predicate: _Predicate[_T] | None, iterable: Iterable[_T], /) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

class groupby(Iterator[tuple[_T_co, Iterator[_S_co]]], Generic[_T_co, _S_co]):
class groupby(Generic[_T_co, _S_co]):
@overload
def __new__(cls, iterable: Iterable[_T1], key: None = None) -> groupby[_T1, _T1]: ...
@overload
def __new__(cls, iterable: Iterable[_T1], key: Callable[[_T1], _T2]) -> groupby[_T2, _T1]: ...
def __iter__(self) -> Self: ...
def __next__(self) -> tuple[_T_co, Iterator[_S_co]]: ...

class islice(Iterator[_T]):
class islice(Generic[_T]):
@overload
def __init__(self, iterable: Iterable[_T], stop: int | None, /) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = ..., /) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

class starmap(Iterator[_T_co]):
class starmap(Generic[_T_co]):
def __new__(cls, function: Callable[..., _T], iterable: Iterable[Iterable[Any]], /) -> starmap[_T]: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T_co: ...

class takewhile(Iterator[_T]):
class takewhile(Generic[_T]):
def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T: ...

def tee(iterable: Iterable[_T], n: int = 2, /) -> tuple[Iterator[_T], ...]: ...

class zip_longest(Iterator[_T_co]):
class zip_longest(Generic[_T_co]):
# one iterable (fillvalue doesn't matter)
@overload
def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ...
Expand Down Expand Up @@ -191,7 +191,7 @@ class zip_longest(Iterator[_T_co]):
def __iter__(self) -> Self: ...
def __next__(self) -> _T_co: ...

class product(Iterator[_T_co]):
class product(Generic[_T_co]):
@overload
def __new__(cls, iter1: Iterable[_T1], /) -> product[tuple[_T1]]: ...
@overload
Expand Down Expand Up @@ -276,7 +276,7 @@ class product(Iterator[_T_co]):
def __iter__(self) -> Self: ...
def __next__(self) -> _T_co: ...

class permutations(Iterator[_T_co]):
class permutations(Generic[_T_co]):
@overload
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> permutations[tuple[_T, _T]]: ...
@overload
Expand All @@ -290,7 +290,7 @@ class permutations(Iterator[_T_co]):
def __iter__(self) -> Self: ...
def __next__(self) -> _T_co: ...

class combinations(Iterator[_T_co]):
class combinations(Generic[_T_co]):
@overload
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[tuple[_T, _T]]: ...
@overload
Expand All @@ -304,7 +304,7 @@ class combinations(Iterator[_T_co]):
def __iter__(self) -> Self: ...
def __next__(self) -> _T_co: ...

class combinations_with_replacement(Iterator[_T_co]):
class combinations_with_replacement(Generic[_T_co]):
@overload
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations_with_replacement[tuple[_T, _T]]: ...
@overload
Expand All @@ -319,13 +319,13 @@ class combinations_with_replacement(Iterator[_T_co]):
def __next__(self) -> _T_co: ...

if sys.version_info >= (3, 10):
class pairwise(Iterator[_T_co]):
class pairwise(Generic[_T_co]):
def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ...
def __iter__(self) -> Self: ...
def __next__(self) -> _T_co: ...

if sys.version_info >= (3, 12):
class batched(Iterator[tuple[_T_co, ...]], Generic[_T_co]):
class batched(Generic[_T_co]):
if sys.version_info >= (3, 13):
def __new__(cls, iterable: Iterable[_T_co], n: int, *, strict: bool = False) -> Self: ...
else:
Expand Down
Loading