@@ -3,15 +3,15 @@ Title: Marking individual TypedDict items as required or potentially-missing
3
3
Author: David Foster <david at dafoster.net>
4
4
Sponsor: Guido van Rossum <guido at python.org>
5
5
Discussions-To: https://mail.python.org/archives/list/
[email protected] /thread/53XVOD5ZUKJ263MWA6AUPEA6J7LBBLNV/
6
- Status: Accepted
6
+ Status: Final
7
7
Type: Standards Track
8
8
Topic: Typing
9
- Content-Type: text/x-rst
10
9
Created: 30-Jan-2021
11
10
Python-Version: 3.11
12
11
Post-History: 31-Jan-2021, 11-Feb-2021, 20-Feb-2021, 26-Feb-2021, 17-Jan-2022, 28-Jan-2022
13
12
Resolution: https://mail.python.org/archives/list/
[email protected] /message/AJEDNVC3FXM5QXNNW5CR4UCT4KI5XVUE/
14
13
14
+ .. canonical-typing-spec :: :ref:`typing:required-notrequired`
15
15
16
16
Abstract
17
17
========
@@ -309,7 +309,8 @@ within the same TypedDict definition:
309
309
310
310
Yes:
311
311
312
- ::
312
+ .. code-block ::
313
+ :class: good
313
314
314
315
from __future__ import annotations # for Python 3.7-3.9
315
316
@@ -319,15 +320,17 @@ Yes:
319
320
320
321
Okay (required for Python 3.5.3-3.6):
321
322
322
- ::
323
+ .. code-block ::
324
+ :class: maybe
323
325
324
326
class Dog(TypedDict):
325
327
name: str
326
328
owner: 'NotRequired[str|None]'
327
329
328
330
No:
329
331
330
- ::
332
+ .. code-block ::
333
+ :class: bad
331
334
332
335
class Dog(TypedDict):
333
336
name: str
@@ -345,7 +348,8 @@ than ``typing.TypedDict`` because the latter will not understand
345
348
346
349
Yes (Python 3.11+ only):
347
350
348
- ::
351
+ .. code-block ::
352
+ :class: good
349
353
350
354
from typing import NotRequired, TypedDict
351
355
@@ -355,7 +359,8 @@ Yes (Python 3.11+ only):
355
359
356
360
Yes (Python <3.11 and 3.11+):
357
361
358
- ::
362
+ .. code-block ::
363
+ :class: good
359
364
360
365
from __future__ import annotations # for Python 3.7-3.9
361
366
@@ -367,7 +372,8 @@ Yes (Python <3.11 and 3.11+):
367
372
368
373
No (Python <3.11 and 3.11+):
369
374
370
- ::
375
+ .. code-block ::
376
+ :class: bad
371
377
372
378
from typing import TypedDict # oops: should import from typing_extensions instead
373
379
from typing_extensions import NotRequired
@@ -667,13 +673,3 @@ Copyright
667
673
668
674
This document is placed in the public domain or under the
669
675
CC0-1.0-Universal license, whichever is more permissive.
670
-
671
-
672
- ..
673
- Local Variables:
674
- mode: indented-text
675
- indent-tabs-mode: nil
676
- sentence-end-double-space: t
677
- fill-column: 70
678
- coding: utf-8
679
- End:
0 commit comments