8000 gh-112194: Convert more examples to doctests in `typing.py` by sobolevn · Pull Request #112195 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112194: Convert more examples to doctests in typing.py #112195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
one more nit
  • Loading branch information
AlexWaygood authored Nov 17, 2023
commit 7b835b754e8a892a0bbb387cd71462574f6d3420
3 changes: 2 additions & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2917,7 +2917,8 @@ def TypedDict(typename, fields=_sentinel, /, *, total=True):
...
>>> a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK
>>> b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check
>>> assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')
>>> Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')
True

The type info can be accessed via the Point2D.__annotations__ dict, and
the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets.
Expand Down
0