|
@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: ... |
|
@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'}
typeshed/stdlib/builtins.pyi
Lines 807 to 818 in 196f69b
typeshed/stdlib/builtins.pyi
Lines 824 to 829 in 196f69b
In stubs,
__init__has 5 overloads andupdate()has 3 overloads. But at runtime,dict.update()accepts everything thatdict.__init__accepts. For example: