| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,7 +45,7 @@ Node classes | |||
| 45 | 45 | ||
| 46 | 46 | This is the base of all AST node classes. The actual node classes are | |
| 47 | 47 | 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 | ||
| 49 | 49 | module and re-exported in :mod:`ast`. | |
| 50 | 50 | ||
| 51 | 51 | There is one class defined for each left-hand side symbol in the abstract | |
@@ -128,14 +128,14 @@ Node classes | |||
| 128 | 128 | ||
| 129 | 129 | .. deprecated:: 3.8 | |
| 130 | 130 | ||
| 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, | ||
| 133 | 133 | but they will be removed in future Python releases. In the meantime, | |
| 134 | 134 | instantiating them will return an instance of a different class. | |
| 135 | 135 | ||
| 136 | 136 | .. deprecated:: 3.9 | |
| 137 | 137 | ||
| 138 | - Old classes :class:`ast.Index` and :class:`ast.ExtSlice` are still | ||
| 138 | + Old classes :class:`!ast.Index` and :class:`!ast.ExtSlice` are still | ||
| 139 | 139 | available, but they will be removed in future Python releases. | |
| 140 | 140 | In the meantime, instantiating them will return an instance of | |
| 141 | 141 | a different class. | |
@@ -1935,8 +1935,7 @@ Function and class definitions | |||
| 1935 | 1935 | .. class:: arg(arg, annotation, type_comment) | |
| 1936 | 1936 | ||
| 1937 | 1937 | 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. | ||
| 1940 | 1939 | ||
| 1941 | 1940 | .. attribute:: type_comment | |
| 1942 | 1941 | ||
@@ -2210,7 +2209,7 @@ and classes for traversing abstract syntax trees: | |||
| 2210 | 2209 | Added ``type_comments``, ``mode='func_type'`` and ``feature_version``. | |
| 2211 | 2210 | ||
| 2212 | 2211 | .. versionchanged:: 3.13 | |
| 2213 | - The minimum supported version for feature_version is now (3,7) | ||
| 2212 | + The minimum supported version for ``feature_version`` is now ``(3, 7)``. | ||
| 2214 | 2213 | The ``optimize`` argument was added. | |
| 2215 | 2214 | ||
| 2216 | 2215 | ||
@@ -2286,8 +2285,8 @@ and classes for traversing abstract syntax trees: | |||
| 2286 | 2285 | .. function:: get_source_segment(source, node, *, padded=False) | |
| 2287 | 2286 | ||
| 2288 | 2287 | Get source code segment of the *source* that generated *node*. | |
| 2289 | - If some location information (:attr:`lineno`, :attr:`end_lineno`, | ||
| 2290 | - :attr:`col_offset`, or :attr:`end_col_offset`) is missing, return ``None``. | ||
| 2288 | + If some location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, | ||
| 2289 | + :attr:`~ast.AST.col_offset`, or :attr:`~ast.AST.end_col_offset`) is missing, return ``None``. | ||
| 2291 | 2290 | ||
| 2292 | 2291 | If *padded* is ``True``, the first line of a multi-line statement will | |
| 2293 | 2292 | be padded with spaces to match its original position. | |
@@ -2298,7 +2297,7 @@ and classes for traversing abstract syntax trees: | |||
| 2298 | 2297 | .. function:: fix_missing_locations(node) | |
| 2299 | 2298 | ||
| 2300 | 2299 | When you compile a node tree with :func:`compile`, the compiler expects | |
| 2301 | - :attr:`lineno` and :attr:`col_offset` attributes for every node that supports | ||
| 2300 | + :attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes for every node that supports | ||
| 2302 | 2301 | them. This is rather tedious to fill in for generated nodes, so this helper | |
| 2303 | 2302 | adds these attributes recursively where not already set, by setting them to | |
| 2304 | 2303 | the values of the parent node. It works recursively starting at *node*. | |
@@ -2313,8 +2312,8 @@ and classes for traversing abstract syntax trees: | |||
| 2313 | 2312 | ||
| 2314 | 2313 | .. function:: copy_location(new_node, old_node) | |
| 2315 | 2314 | ||
| 2316 | - Copy source location (:attr:`lineno`, :attr:`col_offset`, :attr:`end_lineno`, | ||
| 2317 | - and :attr:`end_col_offset`) from *old_node* to *new_node* if possible, | ||
| 2315 | + Copy source location (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :attr:`~ast.AST.end_lineno`, | ||
| 2316 | + and :attr:`~ast.AST.end_col_offset`) from *old_node* to *new_node* if possible, | ||
| 2318 | 2317 | and return *new_node*. | |
| 2319 | 2318 | ||
| 2320 | 2319 | ||
@@ -2360,14 +2359,18 @@ and classes for traversing abstract syntax trees: | |||
| 2360 | 2359 | visited unless the visitor calls :meth:`generic_visit` or visits them | |
| 2361 | 2360 | itself. | |
| 2362 | 2361 | ||
| 2362 | + .. method:: visit_Constant(node) | ||
| 2363 | + | ||
| 2364 | + Handles all constant nodes. | ||
| 2365 | + | ||
| 2363 | 2366 | Don't use the :class:`NodeVisitor` if you want to apply changes to nodes | |
| 2364 | 2367 | during traversal. For this a special visitor exists | |
| 2365 | 2368 | (:class:`NodeTransformer`) that allows modifications. | |
| 2366 | 2369 | ||
| 2367 | 2370 | .. deprecated:: 3.8 | |
| 2368 | 2371 | ||
| 2369 | - Methods :meth:`visit_Num`, :meth:`visit_Str`, :meth:`visit_Bytes`, | ||
| 2370 | - :meth:`visit_NameConstant` and :meth:`visit_Ellipsis` are deprecated | ||
| 2372 | + Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`, | ||
| 2373 | + :meth:`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated | ||
| 2371 | 2374 | now and will not be called in future Python versions. Add the | |
| 2372 | 2375 | :meth:`visit_Constant` method to handle all constant nodes. | |
| 2373 | 2376 | ||
@@ -2396,7 +2399,7 @@ and classes for traversing abstract syntax trees: | |||
| 2396 | 2399 | ) | |
| 2397 | 2400 | ||
| 2398 | 2401 | Keep in mind that if the node you're operating on has child nodes you must | |
| 2399 | - either transform the child nodes yourself or call the :meth:`generic_visit` | ||
| 2402 | + either transform the child nodes yourself or call the :meth:`~ast.NodeVisitor.generic_visit` | ||
| 2400 | 2403 | method for the node first. | |
| 2401 | 2404 | ||
| 2402 | 2405 | For nodes that were part of a collection of statements (that applies to all | |
@@ -2405,7 +2408,7 @@ and classes for traversing abstract syntax trees: | |||
| 2405 | 2408 | ||
| 2406 | 2409 | If :class:`NodeTransformer` introduces new nodes (that weren't part of | |
| 2407 | 2410 | original tree) without giving them location information (such as | |
| 2408 | - :attr:`lineno`), :func:`fix_missing_locations` should be called with | ||
| 2411 | + :attr:`~ast.AST.lineno`), :func:`fix_missing_locations` should be called with | ||
| 2409 | 2412 | the new sub-tree to recalculate the location information:: | |
| 2410 | 2413 | ||
| 2411 | 2414 | tree = ast.parse('foo', mode='eval') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2069,7 +2069,7 @@ Restores instantiation of Windows IOCP event loops from the non-main thread. | |||
| 2069 | 2069 | .. section: Library | |
| 2070 | 2070 | ||
| 2071 | 2071 | Add default implementation of the :meth:`ast.NodeVisitor.visit_Constant` | |
| 2072 | - method which emits a deprecation warning and calls corresponding methody | ||
| 2072 | + method which emits a deprecation warning and calls corresponding methods | ||
| 2073 | 2073 | ``visit_Num()``, ``visit_Str()``, etc. | |
| 2074 | 2074 | ||
| 2075 | 2075 | .. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments