From 91465a1d07e0ff052ca70e8d6ca3374561a33db6 Mon Sep 17 00:00:00 2001 From: Akuli Date: Tue, 7 Dec 2021 17:26:09 +0200 Subject: [PATCH] toposort: Make argument types less restrictive (#6531) --- stubs/toposort/METADATA.toml | 2 +- stubs/toposort/toposort.pyi | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/stubs/toposort/METADATA.toml b/stubs/toposort/METADATA.toml index 6cf9fae44..ccb25250b 100644 --- a/stubs/toposort/METADATA.toml +++ b/stubs/toposort/METADATA.toml @@ -1 +1 @@ -version = "1.6.*" +version = "1.7" diff --git a/stubs/toposort/toposort.pyi b/stubs/toposort/toposort.pyi index 9410d8279..0539e2b29 100644 --- a/stubs/toposort/toposort.pyi +++ b/stubs/toposort/toposort.pyi @@ -1,10 +1,17 @@ -from typing import Any, Iterator, TypeVar +from _typeshed import SupportsItems +from typing import Any, Iterable, Iterator, TypeVar +from typing_extensions import Protocol +_KT_co = TypeVar("_KT_co", covariant=True) +_VT_co = TypeVar("_VT_co", covariant=True) _T = TypeVar("_T") +class _SupportsItemsAndLen(SupportsItems[_KT_co, _VT_co], Protocol[_KT_co, _VT_co]): + def __len__(self) -> int: ... + class CircularDependencyError(ValueError): data: dict[Any, set[Any]] def __init__(self, data: dict[Any, set[Any]]) -> None: ... -def toposort(data: dict[_T, set[_T]]) -> Iterator[set[_T]]: ... -def toposort_flatten(data: dict[_T, set[_T]], sort: bool = ...) -> list[_T]: ... +def toposort(data: _SupportsItemsAndLen[_T, Iterable[_T]]) -> Iterator[set[_T]]: ... +def toposort_flatten(data: _SupportsItemsAndLen[_T, Iterable[_T]], sort: bool = ...) -> list[_T]: ...