mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 14:01:55 +08:00
Unify stdlib/{2,3}/typing.pyi
Also fix signature of IO.seek, IO.truncate, IO.write, and MutableMapping.update Fixes #1016 Note: I couldn't put typing.pyi in 2and3 because of an import cycle when adding `import sys` to 2/typing.pyi
This commit is contained in:
committed by
Łukasz Langa
parent
37a854630c
commit
d43f3be914
@@ -614,9 +614,9 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def popitem(self) -> Tuple[_KT, _VT]: ...
|
||||
def setdefault(self, k: _KT, default: _VT = None) -> _VT: ...
|
||||
@overload
|
||||
def update(self, m: Mapping[_KT, _VT]) -> None: ...
|
||||
def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
|
||||
@overload
|
||||
def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: ...
|
||||
def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
|
||||
def keys(self) -> KeysView[_KT]: ...
|
||||
def values(self) -> ValuesView[_VT]: ...
|
||||
def items(self) -> ItemsView[_KT, _VT]: ...
|
||||
|
||||
@@ -125,9 +125,9 @@ class Counter(Dict[_T, int], Generic[_T]):
|
||||
# Dict.update. Not sure if we should use '# type: ignore' instead
|
||||
# and omit the type from the union.
|
||||
@overload
|
||||
def update(self, m: Mapping[_T, int]) -> None: ...
|
||||
def update(self, m: Mapping[_T, int], **kwargs: int) -> None: ...
|
||||
@overload
|
||||
def update(self, m: Union[Iterable[_T], Iterable[Tuple[_T, int]]]) -> None: ...
|
||||
def update(self, m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ...
|
||||
|
||||
def __add__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
|
||||
def __sub__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
|
||||
|
||||
@@ -310,9 +310,9 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
# known to be a Mapping with unknown type parameters, which is closer
|
||||
# to the behavior we want. See mypy issue #1430.
|
||||
@overload
|
||||
def update(self, m: Mapping[_KT, _VT]) -> None: ...
|
||||
def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
|
||||
@overload
|
||||
def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: ...
|
||||
def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
|
||||
|
||||
Text = str
|
||||
|
||||
@@ -350,9 +350,8 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
|
||||
def seekable(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def tell(self) -> int: ...
|
||||
# TODO None should not be compatible with int
|
||||
@abstractmethod
|
||||
def truncate(self, size: int = ...) -> int: ...
|
||||
def truncate(self, size: Optional[int] = ...) -> int: ...
|
||||
@abstractmethod
|
||||
def writable(self) -> bool: ...
|
||||
# TODO buffer objects
|
||||
|
||||
Reference in New Issue
Block a user