Update documentation of SymbolTableNode#4080
Conversation
mypy/nodes.py
Outdated
| cross_ref = None # type: Optional[str] | ||
| # Was this node created by normalіze_type_alias? | ||
| # | ||
| # TODO: Write a better comment, this is confusing |
There was a problem hiding this comment.
This one distinguishes typing.List and builtins.list (sorry this comment is my fault)
There was a problem hiding this comment.
Thanks for the hint! I'll update the comment.
| are only used for them ('type_override', 'alias_tvars' at least). | ||
| """ | ||
| # TODO: This is a mess. Refactor! | ||
| # TODO: Describe how type aliases work. |
There was a problem hiding this comment.
Type aliases are quite complicated (due to several corner cases). I tried to make some simplifications recently. It seems to me that we can introduce a dedicated SybmolNode (like Var or TypeInfo) and deprecate type_override and friends and just point .node to this new symbol node. This is major refactoring, but I think it may help.
There was a problem hiding this comment.
Yeah, that's what I was thinking about. I'd also like to deprecate the special handling of module references and other special node kinds so that we could remove the kind attribute and replace it with a scope attribute, with only 3 possible values, corresponding to LDEF, GDEF and MDEF. Not sure how feasible this would be. It would be quite a big refactoring in any case.
There was a problem hiding this comment.
Maybe it makes sense to open an issue to track this?
| The most fundamental attributes are 'kind' and 'node'. The 'node' | ||
| attribute defines the AST node that the name refers to. | ||
|
|
||
| For many bindings, including those targeting variables, functions |
There was a problem hiding this comment.
Maybe it will be helpful to note that this is a bit similar to how CPython symbol tables work. There are no .node, only .kind (and there are more than three kinds however). These kinds are used to emit correct lookup opcodes, so that the right .node will be found by the interpreter at runtime (I know this comparison is vague).
There was a problem hiding this comment.
Hmm talking about CPython implementation details might not be helpful, as many readers likely aren't familiar with them.
No description provided.