Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mypy 0.620 and generic type aliases #272

Merged
merged 3 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 46 additions & 7 deletions multidict/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import abc
from typing import (Mapping, MutableMapping, List, Union, Iterable,
Iterator, TypeVar, Generic, Tuple, Dict)

Expand All @@ -14,8 +15,10 @@ _T = TypeVar('_T')


class MultiMapping(Mapping[_S, _T], Generic[_T]):
@abc.abstractmethod
def getall(self, key: _S, default: _T = ...) -> List[_T]: ...

@abc.abstractmethod
def getone(self, key: _S, default: _T = ...) -> _T: ...


Expand All @@ -29,17 +32,21 @@ class MutableMultiMapping(MultiMapping[_T],
MutableMapping[_S, _T],
Generic[_T]):

@abc.abstractmethod
def add(self, key: _S, value: _T) -> None: ...

def extend(self, arg: _Arg = ..., **kwargs: _T) -> None: ...
@abc.abstractmethod
def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...

@abc.abstractmethod
def popone(self, key: _S, default: _T = ...) -> _T: ...

@abc.abstractmethod
def popall(self, key: _S, default: _T = ...) -> List[_T]: ...


class MultiDict(MutableMultiMapping[_T], Generic[_T]):
def __init__(self, arg: _Arg = ..., **kwargs: _T) -> None: ...
def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...

def copy(self) -> MultiDict[_T]: ...

Expand All @@ -53,11 +60,23 @@ class MultiDict(MutableMultiMapping[_T], Generic[_T]):

def __len__(self) -> int: ...

def getall(self, key: _S, default: _T = ...) -> List[_T]: ...

def getone(self, key: _S, default: _T = ...) -> _T: ...

def add(self, key: _S, value: _T) -> None: ...

def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...

def popone(self, key: _S, default: _T = ...) -> _T: ...

def popall(self, key: _S, default: _T = ...) -> List[_T]: ...


class CIMultiDict(MutableMultiMapping[_T], Generic[_T]):
def __init__(self, arg: _Arg = ..., **kwargs: _T) -> None: ...
def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...

def copy(self) -> CIMultiDict[_T]: ...
def copy(self) -> MultiDict[_T]: ...

def __getitem__(self, k: _S) -> _T: ...

Expand All @@ -69,32 +88,52 @@ class CIMultiDict(MutableMultiMapping[_T], Generic[_T]):

def __len__(self) -> int: ...

def getall(self, key: _S, default: _T = ...) -> List[_T]: ...

def getone(self, key: _S, default: _T = ...) -> _T: ...

def add(self, key: _S, value: _T) -> None: ...

def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...

def popone(self, key: _S, default: _T = ...) -> _T: ...

def popall(self, key: _S, default: _T = ...) -> List[_T]: ...


class MultiDictProxy(MultiMapping[_T], Generic[_T]):
def __init__(self, arg: Union[MultiMapping[_T],
MutableMultiMapping[_T]]) -> None: ...

def copy(self) -> MultiDictProxy[_T]: ...
def copy(self) -> MultiDict[_T]: ...

def __getitem__(self, k: _S) -> _T: ...

def __iter__(self) -> Iterator[_S]: ...

def __len__(self) -> int: ...

def getall(self, key: _S, default: _T = ...) -> List[_T]: ...

def getone(self, key: _S, default: _T = ...) -> _T: ...


class CIMultiDictProxy(MultiMapping[_T], Generic[_T]):
def __init__(self, arg: Union[MultiMapping[_T],
MutableMultiMapping[_T]]) -> None: ...

def copy(self) -> CIMultiDictProxy[_T]: ...

def __getitem__(self, k: _S) -> _T: ...

def __iter__(self) -> Iterator[_S]: ...

def __len__(self) -> int: ...

def getall(self, key: _S, default: _T = ...) -> List[_T]: ...

def getone(self, key: _S, default: _T = ...) -> _T: ...

def copy(self) -> CIMultiDict[_T]: ...


def getversion(md: Union[MultiDict[_T],
CIMultiDict[_T],
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ commands = flake8 multidict tests
[testenv:mypy]
skipsdist = True
skip_install = True
deps = mypy==0.610
deps = mypy==0.620
commands = mypy multidict tests

[testenv:manylinux1]
Expand Down