diff --git a/python/helpers/typeshed/stdlib/2/__builtin__.pyi b/python/helpers/typeshed/stdlib/2/__builtin__.pyi index 195d4b18013e..3a79fcb1662d 100644 --- a/python/helpers/typeshed/stdlib/2/__builtin__.pyi +++ b/python/helpers/typeshed/stdlib/2/__builtin__.pyi @@ -574,9 +574,11 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def popitem(self) -> Tuple[_KT, _VT]: ... def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... @overload - def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... + def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def update(self, __m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + @overload + def update(self, **kwargs: _VT) -> None: ... def iterkeys(self) -> Iterator[_KT]: ... def itervalues(self) -> Iterator[_VT]: ... def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ... diff --git a/python/helpers/typeshed/stdlib/2/collections.pyi b/python/helpers/typeshed/stdlib/2/collections.pyi index 3235e9bd12f9..b5d4fef7bf4a 100644 --- a/python/helpers/typeshed/stdlib/2/collections.pyi +++ b/python/helpers/typeshed/stdlib/2/collections.pyi @@ -66,9 +66,11 @@ 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], **kwargs: _VT) -> None: ... + def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ... @overload - def update(self, m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: _VT) -> None: ... + def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ... + @overload + def update(self, **kwargs: int) -> None: ... class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ... diff --git a/python/helpers/typeshed/stdlib/2/typing.pyi b/python/helpers/typeshed/stdlib/2/typing.pyi index dc807a0e0604..843ef5c21cd7 100644 --- a/python/helpers/typeshed/stdlib/2/typing.pyi +++ b/python/helpers/typeshed/stdlib/2/typing.pyi @@ -232,9 +232,11 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): def popitem(self) -> Tuple[_KT, _VT]: ... def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... @overload - def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... + def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def update(self, __m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + @overload + def update(self, **kwargs: _VT) -> None: ... Text = unicode diff --git a/python/helpers/typeshed/stdlib/3/builtins.pyi b/python/helpers/typeshed/stdlib/3/builtins.pyi index d3254c8d4657..a9d31f5e1b41 100644 --- a/python/helpers/typeshed/stdlib/3/builtins.pyi +++ b/python/helpers/typeshed/stdlib/3/builtins.pyi @@ -630,9 +630,11 @@ 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], **kwargs: _VT) -> None: ... + def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def update(self, __m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + @overload + def update(self, **kwargs: _VT) -> None: ... def keys(self) -> KeysView[_KT]: ... def values(self) -> ValuesView[_VT]: ... def items(self) -> ItemsView[_KT, _VT]: ... diff --git a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi index 1ccb98d3c26b..b8bfcf138590 100644 --- a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi @@ -125,9 +125,11 @@ 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], **kwargs: int) -> None: ... + def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ... @overload - def update(self, m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ... + def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ... + @overload + def update(self, **kwargs: int) -> None: ... def __add__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... def __sub__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... diff --git a/python/helpers/typeshed/stdlib/3/typing.pyi b/python/helpers/typeshed/stdlib/3/typing.pyi index e57bcc10056f..6efc0b6dcd52 100644 --- a/python/helpers/typeshed/stdlib/3/typing.pyi +++ b/python/helpers/typeshed/stdlib/3/typing.pyi @@ -323,9 +323,11 @@ 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], **kwargs: _VT) -> None: ... + def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def update(self, __m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + @overload + def update(self, **kwargs: _VT) -> None: ... Text = str diff --git a/python/testData/typeshed/stdlib/2/builtins_test.py b/python/testData/typeshed/stdlib/2/builtins_test.py index 7b0f81b2eaf7..d1b446d5418c 100644 --- a/python/testData/typeshed/stdlib/2/builtins_test.py +++ b/python/testData/typeshed/stdlib/2/builtins_test.py @@ -160,3 +160,11 @@ def test_staticmethod(): # test __dict__.keys() assert set(staticmethod.__dict__.keys()) == {'__init__', '__new__', '__func__', '__get__', '__getattribute__', '__doc__'} + + +def test_dict_update(): + d = {} + d.update({"k1": 1, "v1": 1}) + d.update([("k2", 2), ("v2", 2)]) + d.update(k3=3, v3=3) + assert d == {"k1": 1, "v1": 1, "k2": 2, "v2": 2, "k3": 3, "v3": 3} diff --git a/python/testData/typeshed/stdlib/3/builtins_test.py b/python/testData/typeshed/stdlib/3/builtins_test.py index fdd493142fb9..bf830ab7a72c 100644 --- a/python/testData/typeshed/stdlib/3/builtins_test.py +++ b/python/testData/typeshed/stdlib/3/builtins_test.py @@ -176,4 +176,12 @@ def test_staticmethod(): # test __dict__.keys() assert set(staticmethod.__dict__.keys()) == {'__init__', '__new__', '__func__', '__isabstractmethod__', '__get__', - '__dict__', '__doc__'} \ No newline at end of file + '__dict__', '__doc__'} + + +def test_dict_update(): + d = {} + d.update({"k1": 1, "v1": 1}) + d.update([("k2", 2), ("v2", 2)]) + d.update(k3=3, v3=3) + assert d == {"k1": 1, "v1": 1, "k2": 2, "v2": 2, "k3": 3, "v3": 3} \ No newline at end of file