mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-09 09:59:16 +08:00
Loosen Mapping.update() overloads a little (#14593)
This commit is contained in:
@@ -4,6 +4,10 @@ import os
|
||||
from typing import Any, Dict, Generic, Iterable, Mapping, TypeVar, Union
|
||||
from typing_extensions import Self, assert_type
|
||||
|
||||
###################################################################
|
||||
# Note: tests for `dict.update()` are in `check_MutableMapping.py`.
|
||||
###################################################################
|
||||
|
||||
# These do follow `__init__` overloads order:
|
||||
# mypy and pyright have different opinions about this one:
|
||||
# mypy raises: 'Need type annotation for "bad"'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Union
|
||||
from typing import Any, Hashable, Sequence, Union
|
||||
from typing_extensions import assert_type
|
||||
|
||||
|
||||
@@ -30,6 +30,15 @@ def check_update_method__str_key() -> None:
|
||||
d.update([("", "")]) # type: ignore
|
||||
|
||||
|
||||
def test_keywords_allowed_on_dict_update_where_key_type_is_str_supertype(
|
||||
a: dict[object, Any], b: dict[Hashable, Any], c: dict[Sequence[str], Any], d: dict[str, Any]
|
||||
) -> None:
|
||||
a.update(keyword_args_are_accepted="whatever")
|
||||
b.update(here_too="whooo")
|
||||
c.update(and_here="hooray")
|
||||
d.update(also_here="yay")
|
||||
|
||||
|
||||
def check_setdefault_method() -> None:
|
||||
d: dict[int, str] = {}
|
||||
d2: dict[int, str | None] = {}
|
||||
|
||||
Reference in New Issue
Block a user