@@ -4731,9 +4731,10 @@ class SymbolTableNode:
47314731 they should be correct.
47324732
47334733 Attributes:
4734- node : AST node of definition. Among others, this can be one of
4734+ _node : AST node of definition. Among others, this can be one of
47354735 FuncDef, Var, TypeInfo, TypeVarExpr or MypyFile -- or None
4736- for cross_ref that hasn't been fixed up yet.
4736+ for cross_ref that hasn't been fixed up yet. Should not be accessed
4737+ directly, only via the `node` property.
47374738 kind: Kind of node. Possible values:
47384739 - LDEF: local definition
47394740 - GDEF: global (module-level) definition
@@ -4743,25 +4744,20 @@ class SymbolTableNode:
47434744 module_public: If False, this name won't be imported via
47444745 'from <module> import *'. This has no effect on names within
47454746 classes.
4746- module_hidden: If True, the name will be never exported (needed for
4747+ module_hidden: If True, the name will never be exported (needed for
47474748 stub files)
47484749 cross_ref: For deserialized MypyFile nodes, the referenced module
47494750 name; for other nodes, optionally the name of the referenced object.
47504751 implicit: Was this defined by assignment to self attribute?
47514752 plugin_generated: Was this symbol generated by a plugin?
47524753 (And therefore needs to be removed in aststrip.)
4753- no_serialize: Do not serialize this node if True. This is used to prevent
4754- keys in the cache that refer to modules on which this file does not
4755- depend. Currently this can happen if there is a module not in build
4756- used e.g. like this:
4757- import a.b.c # type: ignore
4758- This will add a submodule symbol to parent module `a` symbol table,
4759- but `a.b` is _not_ added as its dependency. Therefore, we should
4760- not serialize these symbols as they may not be found during fixup
4761- phase, instead they will be re-added during subsequent patch parents
4762- phase.
4763- TODO: Refactor build.py to make dependency tracking more transparent
4764- and/or refactor look-up functions to not require parent patching.
4754+ no_serialize: Do not serialize this node if True. This is used for internal
4755+ and/or temporary symbols such as function redefinitions.
4756+ unfixed: Indicates that this symbol is fresh after deserialization and
4757+ needs fixup, such as resolving cross-references etc.
4758+ stored_info: TypeInfo containing this symbol. Normally code accesses this
4759+ on the `node` attribute, but it may be not ready during deserialization,
4760+ so we temporarily store info on the symbol itself.
47654761
47664762 NOTE: No other attributes should be added to this class unless they
47674763 are shared by all node kinds.
@@ -4831,6 +4827,7 @@ def node(self) -> SymbolNode | None:
48314827 assert node is not None
48324828 if self .stored_info is not None :
48334829 set_info (node , self .stored_info )
4830+ self .stored_info = None
48344831 node .accept (node_fixer )
48354832 self .unfixed = False
48364833 return self ._node
@@ -5276,6 +5273,7 @@ def local_definitions(
52765273
52775274
52785275def set_info (node : SymbolNode , info : TypeInfo ) -> None :
5276+ """Add `info` attribute to all relevant components of the node."""
52795277 if isinstance (node , (FuncDef , Var )):
52805278 node .info = info
52815279 elif isinstance (node , Decorator ):
0 commit comments