@@ -2,18 +2,24 @@ import builtins
22import operator
33import types
44import unittest
5- from _typeshed import IdentityFunction , SupportsGetItem
5+ from _typeshed import IdentityFunction , _KT_contra , _VT_co
66from builtins import next as next
77from collections .abc import Callable , ItemsView , Iterable , Iterator as _Iterator , KeysView , Mapping , ValuesView
88from functools import wraps as wraps
99from importlib .util import spec_from_loader as spec_from_loader
1010from io import BytesIO as BytesIO , StringIO as StringIO
1111from re import Pattern
12- from typing import Any , AnyStr , NoReturn , TypeVar , overload
12+ from typing import Any , AnyStr , NoReturn , Protocol , TypeVar , overload
1313from typing_extensions import Literal
1414
1515from six import moves as moves
1616
17+ # TODO: We should switch to the _typeshed version of SupportsGetItem
18+ # once mypy updates its vendored copy of typeshed and makes a new release
19+ class _SupportsGetItem (Protocol [_KT_contra , _VT_co ]):
20+ def __contains__ (self , __x : Any ) -> bool : ...
21+ def __getitem__ (self , __key : _KT_contra ) -> _VT_co : ...
22+
1723_T = TypeVar ("_T" )
1824_K = TypeVar ("_K" )
1925_V = TypeVar ("_V" )
@@ -65,8 +71,8 @@ unichr = chr
6571
6672def int2byte (i : int ) -> bytes : ...
6773
68- # Should be `byte2int: operator.itemgetter[int]`. But a bug in mypy prevents using TypeVar in itemgetter__call__
69- def byte2int (obj : SupportsGetItem [int , _T ]) -> _T : ...
74+ # Should be `byte2int: operator.itemgetter[int]`. But a bug in mypy prevents using TypeVar in itemgetter.__call__
75+ def byte2int (obj : _SupportsGetItem [int , _T ]) -> _T : ...
7076
7177indexbytes = operator .getitem
7278iterbytes = iter
0 commit comments