diff --git a/stdlib/@tests/test_cases/typing/check_MutableMapping.py b/stdlib/@tests/test_cases/typing/check_MutableMapping.py index d4f951060b35..b4916351703f 100644 --- a/stdlib/@tests/test_cases/typing/check_MutableMapping.py +++ b/stdlib/@tests/test_cases/typing/check_MutableMapping.py @@ -30,6 +30,14 @@ def check_update_method__str_key() -> None: 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] = {} diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index d296c8d92149..d45d6b5076fc 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -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