File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -2294,17 +2294,22 @@ types.
22942294 The keyword-argument syntax is deprecated in 3.11 and will be removed
22952295 in 3.13. It may also be unsupported by static type checkers.
22962296
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::
23002301
23012302 # raises SyntaxError
23022303 class Point2D(TypedDict):
23032304 in: int # 'in' is a keyword
23042305 x-y: int # name with hyphens
23052306
2307+ class Definition(TypedDict):
2308+ __schema: str # mangled to `_Definition__schema`
2309+
23062310 # OK, functional syntax
23072311 Point2D = TypedDict('Point2D', {'in': int, 'x-y': int})
2312+ Definition = TypedDict('Definition', {'__schema': str}) # not mangled
23082313
23092314 By default, all keys must be present in a ``TypedDict ``. It is possible to
23102315 mark individual keys as non-required using :data: `NotRequired `::
You can’t perform that action at this time.
0 commit comments