@@ -572,13 +572,29 @@ main:41: error: Argument 1 to "foo" has incompatible type "**dict[str, str]"; ex
572572[builtins fixtures/dict.pyi]
573573
574574[case testLiteralKwargs]
575- from typing import Literal
575+ from typing import Literal, Mapping, Iterable
576576def func(a: int, b: int) -> None: ...
577577
578+ class GOOD_KW:
579+ def keys(self) -> Iterable[Literal["a", "b"]]: ...
580+ def __getitem__(self, key: str) -> int: ...
581+
582+ class BAD_KW:
583+ def keys(self) -> Iterable[Literal["one", 1]]: ...
584+ def __getitem__(self, key: str) -> int: ...
585+
578586def test(
579- good_kw: dict[Literal["a", "b"], int],
580- bad_kw: dict[Literal["one", 1], int],
587+ good_kw: GOOD_KW,
588+ bad_kw: BAD_KW,
589+ good_dict: dict[Literal["a", "b"], int],
590+ bad_dict: dict[Literal["one", 1], int],
591+ good_mapping: Mapping[Literal["a", "b"], int],
592+ bad_mapping: Mapping[Literal["one", 1], int],
581593) -> None:
582594 func(**good_kw)
583595 func(**bad_kw) # E: Argument after ** must have string keys
596+ func(**good_dict)
597+ func(**bad_dict) # E: Argument after ** must have string keys
598+ func(**good_mapping)
599+ func(**bad_mapping) # E: Argument after ** must have string keys
584600[builtins fixtures/dict.pyi]
0 commit comments