Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stdlib/@tests/test_cases/typing/check_MutableMapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
d: dict[int, int] = {}
d.update({1: 2})
d.update([(1, 2)])
d.update(a=3) # type: ignore

Check failure on line 11 in stdlib/@tests/test_cases/typing/check_MutableMapping.py

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
d.update({1: 2}, a=3) # type: ignore
d.update([(1, 2)], a=3) # type: ignore
d.update({"": 3}) # type: ignore

Check failure on line 14 in stdlib/@tests/test_cases/typing/check_MutableMapping.py

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
d.update({1: ""}) # type: ignore
d.update([("", 3)]) # type: ignore

Check failure on line 16 in stdlib/@tests/test_cases/typing/check_MutableMapping.py

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
d.update([(3, "")]) # type: ignore


Expand All @@ -30,6 +30,14 @@
d.update([("", "")]) # type: ignore


def check_update_kwarg_key_type_accepts_str() -> None:
d1: dict[str | int, int] = {}
d1.update(a=1)

d2: dict[object, int] = {}
d2.update(a=1)


def check_setdefault_method() -> None:
d: dict[int, str] = {}
d2: dict[int, str | None] = {}
Expand Down
6 changes: 3 additions & 3 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,13 @@ class MutableMapping(Mapping[_KT, _VT]):
@overload
def update(self, m: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ...
@overload
def update(self: Mapping[str, _VT], m: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ...
def update(self: Mapping[str | Any, _VT], m: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ...
@overload
def update(self, m: Iterable[tuple[_KT, _VT]], /) -> None: ...
@overload
def update(self: Mapping[str, _VT], m: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...
def update(self: Mapping[str | Any, _VT], m: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...
@overload
def update(self: Mapping[str, _VT], **kwargs: _VT) -> None: ...
def update(self: Mapping[str | Any, _VT], **kwargs: _VT) -> None: ...

Text = str

Expand Down
Loading