Skip to content

PEP 655: Mark as Final #3672

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 3 commits into from
Feb 16, 2024
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
32 changes: 14 additions & 18 deletions peps/pep-0655.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Title: Marking individual TypedDict items as required or potentially-missing
Author: David Foster <david at dafoster.net>
Sponsor: Guido van Rossum <guido at python.org>
Discussions-To: https://mail.python.org/archives/list/[email protected]/thread/53XVOD5ZUKJ263MWA6AUPEA6J7LBBLNV/
Status: Accepted
Status: Final
Type: Standards Track
Topic: Typing
Content-Type: text/x-rst
Created: 30-Jan-2021
Python-Version: 3.11
Post-History: 31-Jan-2021, 11-Feb-2021, 20-Feb-2021, 26-Feb-2021, 17-Jan-2022, 28-Jan-2022
Resolution: https://mail.python.org/archives/list/[email protected]/message/AJEDNVC3FXM5QXNNW5CR4UCT4KI5XVUE/

.. canonical-typing-spec:: :ref:`typing:required-notrequired`

Abstract
========
Expand Down Expand Up @@ -309,7 +309,8 @@ within the same TypedDict definition:

Yes:

::
.. code-block::
:class: good

from __future__ import annotations # for Python 3.7-3.9

Expand All @@ -319,15 +320,17 @@ Yes:

Okay (required for Python 3.5.3-3.6):

::
.. code-block::
:class: maybe

class Dog(TypedDict):
name: str
owner: 'NotRequired[str|None]'

No:

::
.. code-block::
:class: bad

class Dog(TypedDict):
name: str
Expand All @@ -345,7 +348,8 @@ than ``typing.TypedDict`` because the latter will not understand

Yes (Python 3.11+ only):

::
.. code-block::
:class: good

from typing import NotRequired, TypedDict

Expand All @@ -355,7 +359,8 @@ Yes (Python 3.11+ only):

Yes (Python <3.11 and 3.11+):

::
.. code-block::
:class: good

from __future__ import annotations # for Python 3.7-3.9

Expand All @@ -367,7 +372,8 @@ Yes (Python <3.11 and 3.11+):

No (Python <3.11 and 3.11+):

::
.. code-block::
:class: bad

from typing import TypedDict # oops: should import from typing_extensions instead
from typing_extensions import NotRequired
Expand Down Expand Up @@ -667,13 +673,3 @@ Copyright

This document is placed in the public domain or under the
CC0-1.0-Universal license, whichever is more permissive.


..
Local Variables:
mode: indented-text
indent-tabs-mode: nil
sentence-end-double-space: t
fill-column: 70
coding: utf-8
End: