@@ -45,7 +45,7 @@ Node classes
4545
4646 This is the base of all AST node classes. The actual node classes are
4747 derived from the :file: `Parser/Python.asdl ` file, which is reproduced
48- :ref: `above <abstract-grammar >`. They are defined in the :mod: `_ast ` C
48+ :ref: `above <abstract-grammar >`. They are defined in the :mod: `! _ast ` C
4949 module and re-exported in :mod: `ast `.
5050
5151 There is one class defined for each left-hand side symbol in the abstract
@@ -128,14 +128,14 @@ Node classes
128128
129129.. deprecated :: 3.8
130130
131- Old classes :class: `ast.Num `, :class: `ast.Str `, :class: `ast.Bytes `,
132- :class: `ast.NameConstant ` and :class: `ast.Ellipsis ` are still available,
131+ Old classes :class: `! ast.Num `, :class: `! ast.Str `, :class: `! ast.Bytes `,
132+ :class: `! ast.NameConstant ` and :class: `! ast.Ellipsis ` are still available,
133133 but they will be removed in future Python releases. In the meantime,
134134 instantiating them will return an instance of a different class.
135135
136136.. deprecated :: 3.9
137137
138- Old classes :class: `ast.Index ` and :class: `ast.ExtSlice ` are still
138+ Old classes :class: `! ast.Index ` and :class: `! ast.ExtSlice ` are still
139139 available, but they will be removed in future Python releases.
140140 In the meantime, instantiating them will return an instance of
141141 a different class.
@@ -1935,8 +1935,7 @@ Function and class definitions
19351935.. class :: arg(arg, annotation, type_comment)
19361936
19371937 A single argument in a list. ``arg `` is a raw string of the argument
1938- name, ``annotation `` is its annotation, such as a :class: `Str ` or
1939- :class: `Name ` node.
1938+ name; ``annotation `` is its annotation, such as a :class: `Name ` node.
19401939
19411940 .. attribute :: type_comment
19421941
@@ -2280,8 +2279,8 @@ and classes for traversing abstract syntax trees:
22802279.. function :: get_source_segment(source, node, *, padded=False)
22812280
22822281 Get source code segment of the *source * that generated *node *.
2283- If some location information (:attr: `lineno `, :attr: `end_lineno `,
2284- :attr: `col_offset `, or :attr: `end_col_offset `) is missing, return ``None ``.
2282+ If some location information (:attr: `~ast.AST. lineno `, :attr: `~ast.AST. end_lineno `,
2283+ :attr: `~ast.AST. col_offset `, or :attr: `~ast.AST. end_col_offset `) is missing, return ``None ``.
22852284
22862285 If *padded * is ``True ``, the first line of a multi-line statement will
22872286 be padded with spaces to match its original position.
@@ -2292,7 +2291,7 @@ and classes for traversing abstract syntax trees:
22922291.. function :: fix_missing_locations(node)
22932292
22942293 When you compile a node tree with :func: `compile `, the compiler expects
2295- :attr: `lineno ` and :attr: `col_offset ` attributes for every node that supports
2294+ :attr: `~ast.AST. lineno ` and :attr: `~ast.AST. col_offset ` attributes for every node that supports
22962295 them. This is rather tedious to fill in for generated nodes, so this helper
22972296 adds these attributes recursively where not already set, by setting them to
22982297 the values of the parent node. It works recursively starting at *node *.
@@ -2307,8 +2306,8 @@ and classes for traversing abstract syntax trees:
23072306
23082307.. function :: copy_location(new_node, old_node)
23092308
2310- Copy source location (:attr: `lineno `, :attr: `col_offset `, :attr: `end_lineno `,
2311- and :attr: `end_col_offset `) from *old_node * to *new_node * if possible,
2309+ Copy source location (:attr: `~ast.AST. lineno `, :attr: `~ast.AST. col_offset `, :attr: `~ast.AST. end_lineno `,
2310+ and :attr: `~ast.AST. end_col_offset `) from *old_node * to *new_node * if possible,
23122311 and return *new_node *.
23132312
23142313
@@ -2354,14 +2353,18 @@ and classes for traversing abstract syntax trees:
23542353 visited unless the visitor calls :meth: `generic_visit ` or visits them
23552354 itself.
23562355
2356+ .. method :: visit_Constant(node)
2357+
2358+ Handles all constant nodes.
2359+
23572360 Don't use the :class: `NodeVisitor ` if you want to apply changes to nodes
23582361 during traversal. For this a special visitor exists
23592362 (:class: `NodeTransformer `) that allows modifications.
23602363
23612364 .. deprecated :: 3.8
23622365
2363- Methods :meth: `visit_Num `, :meth: `visit_Str `, :meth: `visit_Bytes `,
2364- :meth: `visit_NameConstant ` and :meth: `visit_Ellipsis ` are deprecated
2366+ Methods :meth: `! visit_Num `, :meth: `! visit_Str `, :meth: `! visit_Bytes `,
2367+ :meth: `! visit_NameConstant ` and :meth: `! visit_Ellipsis ` are deprecated
23652368 now and will not be called in future Python versions. Add the
23662369 :meth: `visit_Constant ` method to handle all constant nodes.
23672370
@@ -2390,7 +2393,7 @@ and classes for traversing abstract syntax trees:
23902393 )
23912394
23922395 Keep in mind that if the node you're operating on has child nodes you must
2393- either transform the child nodes yourself or call the :meth: `generic_visit `
2396+ either transform the child nodes yourself or call the :meth: `~ast.NodeVisitor. generic_visit `
23942397 method for the node first.
23952398
23962399 For nodes that were part of a collection of statements (that applies to all
@@ -2399,7 +2402,7 @@ and classes for traversing abstract syntax trees:
23992402
24002403 If :class: `NodeTransformer ` introduces new nodes (that weren't part of
24012404 original tree) without giving them location information (such as
2402- :attr: `lineno `), :func: `fix_missing_locations ` should be called with
2405+ :attr: `~ast.AST. lineno `), :func: `fix_missing_locations ` should be called with
24032406 the new sub-tree to recalculate the location information::
24042407
24052408 tree = ast.parse('foo', mode='eval')
0 commit comments