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.
2475
2475
2476
2476
This functional syntax allows defining keys which are not valid
2477
2477
: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::
2479
2480
2480
2481
# raises SyntaxError
2481
2482
class Point2D(TypedDict):
2482
2483
in: int # 'in' is a keyword
2483
2484
x-y: int # name with hyphens
2484
2485
2486
+ class Definition(TypedDict):
2487
+ __schema: str # mangled to `_Definition__schema`
2488
+
2485
2489
# OK, functional syntax
2486
2490
Point2D = TypedDict('Point2D', {'in': int, 'x-y': int})
2491
+ Definition = TypedDict('Definition', {'__schema': str}) # not mangled
2487
2492
2488
2493
By default, all keys must be present in a ``TypedDict ``. It is possible to
2489
2494
mark individual keys as non-required using :data: `NotRequired `::
You can’t perform that action at this time.
0 commit comments