mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-09 13:02:22 +08:00
Introduce Mapping-like protocols (#4325)
typing.Mapping is not a protocol, which has caused problems in the past. (E.g. python/typeshed#3569, see also python/typeshed#3576.) This introduces a few narrow protocols to _typeshed.pyi that can be used in place of Mapping. Not all uses of Mapping can be replaced. For example, cgi.FieldStorage explictly checks whether the supplied headers argument is a Mapping instance.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
from typing import Generic, Iterable, Mapping, Optional, Tuple, TypeVar
|
||||
from _typeshed import SupportsItems
|
||||
from typing import Generic, Iterable, Optional, Tuple, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class TopologicalSorter(Generic[_T]):
|
||||
def __init__(self, graph: Optional[Mapping[_T, Iterable[_T]]] = ...) -> None: ...
|
||||
def __init__(self, graph: Optional[SupportsItems[_T, Iterable[_T]]] = ...) -> None: ...
|
||||
def add(self, node: _T, *predecessors: _T) -> None: ...
|
||||
def prepare(self) -> None: ...
|
||||
def is_active(self) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user