File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -2551,15 +2551,20 @@ types.
2551
2551
2552
2552
This functional syntax allows defining keys which are not valid
2553
2553
:ref: `identifiers <identifiers >`, for example because they are
2554
- keywords or contain hyphens::
2554
+ keywords or contain hyphens, or when key names must not be
2555
+ :ref: `mangled <private-name-mangling >` like regular private names::
2555
2556
2556
2557
# raises SyntaxError
2557
2558
class Point2D(TypedDict):
2558
2559
in: int # 'in' is a keyword
2559
2560
x-y: int # name with hyphens
2560
2561
2562
+ class Definition(TypedDict):
2563
+ __schema: str # mangled to `_Definition__schema`
2564
+
2561
2565
# OK, functional syntax
2562
2566
Point2D = TypedDict('Point2D', {'in': int, 'x-y': int})
2567
+ Definition = TypedDict('Definition', {'__schema': str}) # not mangled
2563
2568
2564
2569
By default, all keys must be present in a ``TypedDict ``. It is possible to
2565
2570
mark individual keys as non-required using :data: `NotRequired `::
You can’t perform that action at this time.
0 commit comments