File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -2294,17 +2294,22 @@ types.
2294
2294
The keyword-argument syntax is deprecated in 3.11 and will be removed
2295
2295
in 3.13. It may also be unsupported by static type checkers.
2296
2296
2297
- The functional syntax should also be used when any of the keys are not valid
2298
- :ref: `identifiers <identifiers >`, for example because they are keywords or contain hyphens.
2299
- Example::
2297
+ This functional syntax allows defining keys which are not valid
2298
+ :ref: `identifiers <identifiers >`, for example because they are
2299
+ keywords or contain hyphens, or when key names must not be
2300
+ :ref: `mangled <private-name-mangling >` like regular private names::
2300
2301
2301
2302
# raises SyntaxError
2302
2303
class Point2D(TypedDict):
2303
2304
in: int # 'in' is a keyword
2304
2305
x-y: int # name with hyphens
2305
2306
2307
+ class Definition(TypedDict):
2308
+ __schema: str # mangled to `_Definition__schema`
2309
+
2306
2310
# OK, functional syntax
2307
2311
Point2D = TypedDict('Point2D', {'in': int, 'x-y': int})
2312
+ Definition = TypedDict('Definition', {'__schema': str}) # not mangled
2308
2313
2309
2314
By default, all keys must be present in a ``TypedDict ``. It is possible to
2310
2315
mark individual keys as non-required using :data: `NotRequired `::
You can’t perform that action at this time.
0 commit comments