mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-24 21:01:52 +08:00
Introduce SupportsContainsAndGetItem (#11827)
This commit is contained in:
@@ -151,13 +151,22 @@ class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
|
||||
def keys(self) -> Iterable[_KT]: ...
|
||||
def __getitem__(self, key: _KT, /) -> _VT_co: ...
|
||||
|
||||
# stable
|
||||
# This protocol is currently under discussion. Use SupportsGetItemAndContains
|
||||
# instead, if you require the __contains__ method.
|
||||
# See https://github.com/python/typeshed/issues/11822.
|
||||
class SupportsGetItem(Protocol[_KT_contra, _VT_co]):
|
||||
def __contains__(self, x: Any, /) -> bool: ...
|
||||
def __getitem__(self, key: _KT_contra, /) -> _VT_co: ...
|
||||
|
||||
# stable
|
||||
class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]):
|
||||
class SupportsContainsAndGetItem(Protocol[_KT_contra, _VT_co]):
|
||||
def __contains__(self, x: Any, /) -> bool: ...
|
||||
def __getitem__(self, key: _KT_contra, /) -> _VT_co: ...
|
||||
|
||||
# stable
|
||||
class SupportsItemAccess(Protocol[_KT_contra, _VT]):
|
||||
def __contains__(self, x: Any, /) -> bool: ...
|
||||
def __getitem__(self, key: _KT_contra, /) -> _VT: ...
|
||||
def __setitem__(self, key: _KT_contra, value: _VT, /) -> None: ...
|
||||
def __delitem__(self, key: _KT_contra, /) -> None: ...
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from _typeshed import SupportsGetItem, SupportsItemAccess, Unused
|
||||
from _typeshed import SupportsContainsAndGetItem, SupportsGetItem, SupportsItemAccess, Unused
|
||||
from builtins import list as _list, type as _type
|
||||
from collections.abc import Iterable, Iterator, Mapping
|
||||
from email.message import Message
|
||||
@@ -85,7 +85,7 @@ class FieldStorage:
|
||||
fp: IO[Any] | None = None,
|
||||
headers: Mapping[str, str] | Message | None = None,
|
||||
outerboundary: bytes = b"",
|
||||
environ: SupportsGetItem[str, str] = ...,
|
||||
environ: SupportsContainsAndGetItem[str, str] = ...,
|
||||
keep_blank_values: int = 0,
|
||||
strict_parsing: int = 0,
|
||||
limit: int | None = None,
|
||||
|
||||
Reference in New Issue
Block a user