simvx.core.scene_io.source._source_ast.names¶
What an ast statement binds and what it merely names.
The two questions the tier above asks of every statement: which names it
establishes (so a removal knows what it carries off) and which names it writes
at all (so a removal knows what would be left standing on nothing, and a rename
knows what to rewrite). Attributes are spelled self.<name> in both answers,
which is how the tier above tells the two kinds apart.
Where ast is better than a concrete tree here, it is used: a name bound by a
match capture pattern is a binding this file reports and no grammar table
had to be taught. Where ast is worse, it is worse in one direction only: the
names it stores as plain strings rather than as nodes – an except ... as e,
an import’s module path, a global declaration, a parameter – are
bindings this file still reports but mentions it does not, so a rename leaves
them alone. That is the safe direction: a rename that stops short is visible,
and one that reaches into a parameter of a nested function would be wrong.
Module Contents¶
Functions¶
Every name |
|
Every name |
|
Every occurrence of the local |
|
What an import imports, as |
|
The module a |
Data¶
API¶
- simvx.core.scene_io.source._source_ast.names.__all__¶
[‘bound_names’, ‘import_module_path’, ‘imported_names’, ‘local_name_nodes’, ‘mentioned_names’]
- simvx.core.scene_io.source._source_ast.names.bound_names(node: ast.AST) set[str][source]¶
Every name
nodebinds, attributes spelledself.<name>.A statement carrying a block is asked about its whole block, since a name bound inside one is bound by the statement as far as anything outside it can tell. The two bodies that bind only for themselves are the exception: a
lambdais not descended into at all, and a nesteddeforclasscontributes only the name it is given.
- simvx.core.scene_io.source._source_ast.names.mentioned_names(node: ast.AST) set[str][source]¶
Every name
nodewrites, bound there or not,self.<name>for attributes.
- simvx.core.scene_io.source._source_ast.names.local_name_nodes(node: ast.AST, name: str) list[ast.Name][source]¶
Every occurrence of the local
nameundernode, in source order.The rename surface: each of these spells a variable and nothing else, so replacing its span is a rename. The
selfofself.herois not one of them, because that occurrence names an attribute rather than a local.