From 34a5fcf87e7fc762216095ac75e4d030aaca8587 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Sat, 9 May 2020 13:14:55 +0200 Subject: Improve type annotations of Map.update and MapMutation.update --- immutables/_map.pyi | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/immutables/_map.pyi b/immutables/_map.pyi index c483f8f..bea69f3 100644 --- a/immutables/_map.pyi +++ b/immutables/_map.pyi @@ -7,6 +7,7 @@ from typing import Literal from typing import Mapping from typing import MutableMapping from typing import NoReturn +from typing import overload from typing import Tuple from typing import Type from typing import TypeVar @@ -46,8 +47,11 @@ class Map(Mapping[K, V]): def __reduce__(self) -> Tuple[Type[Map], Tuple[dict]]: ... def __len__(self) -> int: ... def __eq__(self, other: Any) -> bool: ... + @overload + def update(self, **kw: V) -> Map[str, V]: ... + @overload def update( - self, col: Union[Mapping[K, V], Iterable[Tuple[K, V]]] = ..., **kw: V + self, col: Union[Mapping[K, V], Iterable[Tuple[K, V]]], **kw: V ) -> Map[K, V]: ... def mutate(self) -> MapMutation[K, V]: ... def set(self, key: K, val: V) -> Map[K, V]: ... @@ -79,9 +83,12 @@ class MapMutation(MutableMapping[K, V]): def get(self, key: K, default: D = ...) -> Union[V, D]: ... def __getitem__(self, key: K) -> V: ... def __contains__(self, key: Any) -> bool: ... + @overload + def update(self, **kw: V) -> None: ... + @overload def update( - self, col: Union[Mapping[K, V], Iterable[Tuple[K, V]]] = ..., **kw: V - ): ... + self, col: Union[Mapping[K, V], Iterable[Tuple[K, V]]], **kw: V + ) -> None: ... def finish(self) -> Map[K, V]: ... def __len__(self) -> int: ... def __eq__(self, other: Any) -> bool: ... -- cgit v1.2.3