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. Attributes: node: AST node of definition. Among others, this can be one of FuncDef, Var, TypeInfo, TypeVarExpr or MypyFile -- or None for cross_ref that hasn't been fixed up yet. kind: Kind of node. Possible values: - LDEF: local definition - GDEF: global (module-level) definition - MDEF: class member definition - UNBOUND_IMPORTED: temporary kind for imported names (we don't know the final kind yet) module_public: If False, this name won't be imported via 'from <module> import *'. This has no effect on names within classes. module_hidden: If True, the name will be never exported (needed for stub files) cross_ref: For deserialized MypyFile nodes, the referenced module name; for other nodes, optionally the name of the referenced object. 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.) no_serialize: Do not serialize this node if True. This is used to prevent 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 |
Undocumented |
Instance Variable | implicit |
Undocumented |
Instance Variable | kind |
Undocumented |
Instance Variable | module |
Undocumented |
Instance Variable | module |
Undocumented |
Instance Variable | no |
Undocumented |
Instance Variable | node |
Undocumented |
Instance Variable | plugin |
Undocumented |
Property | fullname |
Undocumented |
Property | type |
Undocumented |
int
, node: SymbolNode|None
, module_public: bool
= True, implicit: bool
= False, module_hidden: bool
= False, *, plugin_generated: bool
= False, no_serialize: bool
= False):
(source)
¶
Undocumented