Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions peps/pep-0728.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ extra items::
name: str

def f(movie: Movie) -> None:
del movie["name"] # Not OK. The value type of 'name' is 'Required[int]'
del movie["name"] # Not OK. The value type of 'name' is 'Required[str]'
del movie["year"] # OK. The value type of 'year' is 'NotRequired[int]'

Interaction with ``Unpack``
Expand Down Expand Up @@ -726,8 +726,8 @@ with signatures matching ``dict[str, VT]``
reveal_type(not_required_num_dict.popitem()) # OK. Revealed type is 'tuple[str, int]'

def f(not_required_num_dict: IntDictWithNum, key: str):
not_required_num_dict[key] = 42 # OK
del not_required_num_dict[key] # OK
not_required_num_dict[key] = 42 # OK
del not_required_num_dict[key] # OK

:ref:`Notes on indexed accesses <pep728-type-narrowing>` from the previous section
still apply.
Expand All @@ -741,7 +741,7 @@ because such dict can be a subtype of dict::
def f(might_not_be_a_builtin_dict: dict[str, int]):
int_dict: IntDict = might_not_be_a_builtin_dict # Not OK

not_a_builtin_dict: CustomDict = {"num": 1}
not_a_builtin_dict = CustomDict({"num": 1})
f(not_a_builtin_dict)

Runtime behavior
Expand Down