From 70c2274e943554149260d6d6d062b7f4803493e4 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Sat, 16 Apr 2016 16:30:15 +0100 Subject: [PATCH] Update dict(...) to accept keyword arguments (#147) We can't describe the fact that a keyword argument results in a 'str' dictionary key in a stub. This needs to be handled elsewhere. --- stdlib/3/builtins.pyi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 59a364515..26f384852 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -491,12 +491,14 @@ class list(MutableSequence[_T], Generic[_T]): def __le__(self, x: List[_T]) -> bool: ... class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): + # NOTE: Keyword arguments are special. If they are used, _KT must include + # str, but we have no way of enforcing it here. @overload - def __init__(self) -> None: ... + def __init__(self, **kwargs: _VT) -> None: ... @overload - def __init__(self, map: Mapping[_KT, _VT]) -> None: ... + def __init__(self, map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def __init__(self, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... # TODO keyword args + def __init__(self, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... def clear(self) -> None: ... def copy(self) -> Dict[_KT, _VT]: ... def get(self, k: _KT, default: _VT = None) -> _VT: ...