File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -2475,15 +2475,20 @@ types.
24752475
24762476 This functional syntax allows defining keys which are not valid
24772477 :ref: `identifiers <identifiers >`, for example because they are
2478- keywords or contain hyphens::
2478+ keywords or contain hyphens, or when key names must not be
2479+ :ref: `mangled <private-name-mangling >` like regular private names::
24792480
24802481 # raises SyntaxError
24812482 class Point2D(TypedDict):
24822483 in: int # 'in' is a keyword
24832484 x-y: int # name with hyphens
24842485
2486+ class Definition(TypedDict):
2487+ __schema: str # mangled to `_Definition__schema`
2488+
24852489 # OK, functional syntax
24862490 Point2D = TypedDict('Point2D', {'in': int, 'x-y': int})
2491+ Definition = TypedDict('Definition', {'__schema': str}) # not mangled
24872492
24882493 By default, all keys must be present in a ``TypedDict ``. It is possible to
24892494 mark individual keys as non-required using :data: `NotRequired `::
You can’t perform that action at this time.
0 commit comments