Skip to content

Clean up node kinds in SymbolTableNode #4082

Open

Description

@JukkaL

It seems like we could remove the special handling of module references and other special node kinds in SymbolTableNode so that we could remove the kind attribute and replace it with a scope attribute, with only 3 possible values, corresponding to the current kinds LDEF, GDEF and MDEF. We'd create new SymbolNode subclasses for some of the node kinds. For module references we can perhaps just use a MypyFile target node as a marker. We could move some attributes that are specific to type aliases to live in the new SymbolNode subclass.

From #4080 (comment):

@ilevkivskyi :

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.

Activity

  1. ilevkivskyi commented on Oct 9, 2017

    @ilevkivskyi
    Member

    Actually it looks like having a dedicated ModuleRef symbol node will solve #3500 and other long standing problems with conditional imports and imports in try: ... except: .... We can have something like this:

    class ModuleRef(SymbolNode):
        imports: List[MypyFile]

    and then give precise types on attribute access. (This may also simplify creating module aliases.)

  2. self-assigned this
    on Feb 1, 2018
  3. removed their assignment
    on Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions