Skip to content

Clean up node kinds in SymbolTableNode #4082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JukkaL opened this issue Oct 9, 2017 · 1 comment
Open

Clean up node kinds in SymbolTableNode #4082

JukkaL opened this issue Oct 9, 2017 · 1 comment
Labels
priority-0-high refactoring Changing mypy's internals

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 9, 2017

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.

@ilevkivskyi
Copy link
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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-0-high refactoring Changing mypy's internals
Projects
None yet
Development

No branches or pull requests

2 participants