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
14 changes: 7 additions & 7 deletions docs/spec/typeddict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,15 @@ Discussion:
x: int
y: str

def f(a: A) -> None:
a['y'] = 1
def f(a: A) -> None:
a['y'] = 1

def g(b: B) -> None:
f(b) # Type check error: 'B' not assignable to 'A'
def g(b: B) -> None:
f(b) # Type check error: 'B' not assignable to 'A'

c: C = {'x': 0, 'y': 'foo'}
g(c)
c['y'] + 'bar' # Runtime error: int + str
c: C = {'x': 0, 'y': 'foo'}
g(c)
c['y'] + 'bar' # Runtime error: int + str

* A TypedDict isn't :term:`assignable` to any ``Dict[...]`` type, since
dictionary types allow destructive operations, including ``clear()``. They
Expand Down