-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
Lines 807 to 818 in 196f69b
| @overload | |
| def __init__(self: dict[_KT, _VT]) -> None: ... | |
| @overload | |
| def __init__(self: dict[str, _VT], **kwargs: _VT) -> None: ... | |
| @overload | |
| def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ... | |
| @overload | |
| def __init__(self, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... | |
| # Next overload is for dict(string.split(sep) for string in iterable) | |
| # Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error | |
| @overload | |
| def __init__(self: dict[str, str], iterable: Iterable[list[str]]) -> None: ... |
Lines 824 to 829 in 196f69b
| @overload | |
| def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... | |
| @overload | |
| def update(self, __m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... | |
| @overload | |
| def update(self, **kwargs: _VT) -> None: ... |
In stubs, __init__ has 5 overloads and update() has 3 overloads. But at runtime, dict.update() accepts everything that dict.__init__ accepts. For example:
>>> d={}
>>> d.update((s.split('=') for s in ['a=b', 'c=d']), lol='wut')
>>> d
{'a': 'b', 'c': 'd', 'lol': 'wut'}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels