Skip to content

Commit

Permalink
Revert #644, restore type annotations to as-of 5.2.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jan 24, 2022
1 parent 572ce02 commit b915d0d
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions multidict/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class istr(str): ...

upstr = istr

_S = TypeVar("_S", str, istr)
_S = Union[str, istr]

_T = TypeVar("_T")

Expand All @@ -39,17 +39,13 @@ class MultiMapping(Mapping[_S, _T_co]):
@abc.abstractmethod
def getone(self, key: _S, default: _D) -> Union[_T_co, _D]: ...

_Arg = Union[
Mapping[_S, _T], Dict[_S, _T], MultiMapping[_S, _T], Iterable[Tuple[_S, _T]]
]
_Arg = Union[Mapping[_S, _T], Dict[_S, _T], MultiMapping[_T], Iterable[Tuple[_S, _T]]]

class MutableMultiMapping(
MultiMapping[_S, _T], MutableMapping[_S, _T], Generic[_S, _T]
):
class MutableMultiMapping(MultiMapping[_T], MutableMapping[_S, _T], Generic[_T]):
@abc.abstractmethod
def add(self, key: _S, value: _T) -> None: ...
@abc.abstractmethod
def extend(self, arg: _Arg[_S, _T] = ..., **kwargs: _T) -> None: ...
def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
@overload
@abc.abstractmethod
def popone(self, key: _S) -> _T: ...
Expand All @@ -63,8 +59,8 @@ class MutableMultiMapping(
@abc.abstractmethod
def popall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...

class MultiDict(MutableMultiMapping[str, _T]):
def __init__(self, arg: _Arg[_S, _T] = ..., **kwargs: _T) -> None: ...
class MultiDict(MutableMultiMapping[_T], Generic[_T]):
def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
def copy(self) -> MultiDict[_T]: ...
def __getitem__(self, k: _S) -> _T: ...
def __setitem__(self, k: _S, v: _T) -> None: ...
Expand All @@ -80,7 +76,7 @@ class MultiDict(MutableMultiMapping[str, _T]):
@overload
def getone(self, key: _S, default: _D) -> Union[_T, _D]: ...
def add(self, key: _S, value: _T) -> None: ...
def extend(self, arg: _Arg[_S, _T] = ..., **kwargs: _T) -> None: ...
def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
@overload
def popone(self, key: _S) -> _T: ...
@overload
Expand All @@ -90,8 +86,8 @@ class MultiDict(MutableMultiMapping[str, _T]):
@overload
def popall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...

class CIMultiDict(MutableMultiMapping[istr, _T]):
def __init__(self, arg: _Arg[_S, _T] = ..., **kwargs: _T) -> None: ...
class CIMultiDict(MutableMultiMapping[_T], Generic[_T]):
def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
def copy(self) -> CIMultiDict[_T]: ...
def __getitem__(self, k: _S) -> _T: ...
def __setitem__(self, k: _S, v: _T) -> None: ...
Expand All @@ -107,7 +103,7 @@ class CIMultiDict(MutableMultiMapping[istr, _T]):
@overload
def getone(self, key: _S, default: _D) -> Union[_T, _D]: ...
def add(self, key: _S, value: _T) -> None: ...
def extend(self, arg: _Arg[_S, _T] = ..., **kwargs: _T) -> None: ...
def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
@overload
def popone(self, key: _S) -> _T: ...
@overload
Expand All @@ -117,9 +113,9 @@ class CIMultiDict(MutableMultiMapping[istr, _T]):
@overload
def popall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...

class MultiDictProxy(MultiMapping[str, _T]):
class MultiDictProxy(MultiMapping[_T], Generic[_T]):
def __init__(
self, arg: Union[MultiDict[_T], MultiDictProxy[_T]]
self, arg: Union[MultiMapping[_T], MutableMultiMapping[_T]]
) -> None: ...
def copy(self) -> MultiDict[_T]: ...
def __getitem__(self, k: _S) -> _T: ...
Expand All @@ -134,11 +130,10 @@ class MultiDictProxy(MultiMapping[str, _T]):
@overload
def getone(self, key: _S, default: _D) -> Union[_T, _D]: ...

class CIMultiDictProxy(MultiMapping[istr, _T]):
class CIMultiDictProxy(MultiMapping[_T], Generic[_T]):
def __init__(
self, arg: Union[CIMultiDict[_T], CIMultiDictProxy[_T]]
self, arg: Union[MultiMapping[_T], MutableMultiMapping[_T]]
) -> None: ...
def copy(self) -> CIMultiDict[_T]: ...
def __getitem__(self, k: _S) -> _T: ...
def __iter__(self) -> Iterator[_S]: ...
def __len__(self) -> int: ...
Expand All @@ -150,12 +145,8 @@ class CIMultiDictProxy(MultiMapping[istr, _T]):
def getone(self, key: _S) -> _T: ...
@overload
def getone(self, key: _S, default: _D) -> Union[_T, _D]: ...
def copy(self) -> CIMultiDict[_T]: ...

def getversion(
md: Union[
MultiDict[_T],
CIMultiDict[_T],
MultiDictProxy[_T],
CIMultiDictProxy[_T],
]
md: Union[MultiDict[_T], CIMultiDict[_T], MultiDictProxy[_T], CIMultiDictProxy[_T]]
) -> int: ...

0 comments on commit b915d0d

Please sign in to comment.