class SymbolTableNode: (source)
Description of a name binding in a symbol table.
These are only used as values in module (global), function (local) and class symbol tables (see SymbolTable). The name that is bound is the key in SymbolTable.
Symbol tables don't contain direct references to AST nodes primarily because there can be multiple symbol table references to a single AST node (due to imports and aliases), and different references can behave differently. This class describes the unique properties of each reference.
The most fundamental attribute is 'node', which is the AST node that the name refers to.
The kind is usually one of LDEF, GDEF or MDEF, depending on the scope of the definition. These three kinds can usually be used interchangeably and the difference between local, global and class scopes is mostly descriptive, with no semantic significance. However, some tools that consume mypy ASTs may care about these so they should be correct.
implicit: Was this defined by assignment to self attribute? plugin_generated: Was this symbol generated by a plugin?
(And therefore needs to be removed in aststrip.)
keys in the cache that refer to modules on which this file does not depend. Currently this can happen if there is a module not in build used e.g. like this:
import a.b.c # type: ignore
This will add a submodule symbol to parent module a
symbol table,
but a.b
is _not_ added as its dependency. Therefore, we should
not serialize these symbols as they may not be found during fixup
phase, instead they will be re-added during subsequent patch parents
phase.
TODO: Refactor build.py to make dependency tracking more transparent
and/or refactor look-up functions to not require parent patching.
NOTE: No other attributes should be added to this class unless they are shared by all node kinds.
Class Method | deserialize |
Undocumented |
Method | __init__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | copy |
Undocumented |
Method | serialize |
Serialize a SymbolTableNode. |
Class Variable | __slots__ |
Undocumented |
Instance Variable | cross_ref |
Undocumented |
Instance Variable | implicit |
Undocumented |
Instance Variable | kind |
Undocumented |
Instance Variable | module_hidden |
Undocumented |
Instance Variable | module_public |
Undocumented |
Instance Variable | no_serialize |
Undocumented |
Instance Variable | node |
Undocumented |
Instance Variable | plugin_generated |
Undocumented |
Property | fullname |
Undocumented |
Property | type |
Undocumented |
Undocumented
Parameters | |
kind:int | Undocumented |
node:Optional[ | Undocumented |
module_public:bool | Undocumented |
implicit:bool | Undocumented |
module_hidden:bool | Undocumented |
plugin_generated:bool | Undocumented |
no_serialize:bool | Undocumented |
Serialize a SymbolTableNode.
Parameters | |
prefix:str | Undocumented |
name:str | Undocumented |
Returns | |
JsonDict | Undocumented |