8000 [WIP] Tighten Lvalues and remove all references to Node by elazarg · Pull Request #2221 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

[WIP] Tighten Lvalues and remove all references to Node #2221

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

Closed
wants to merge 14 commits into from
Closed
Prev Previous commit
Next Next commit
remove Node from binder
  • Loading branch information
elazarg committed Oct 5, 2016
commit fa752e309963bec5947ae6831f1726fb58eb7eb0
16 changes: 8 additions & 8 deletions mypy/binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,20 @@ def _get(self, key: Key, index: int=-1) -> Type:
return self.frames[i][key]
return None

def push(self, node: Node, typ: Type) -> None:
if not node.literal:
def push(self, expr: Expression, typ: Type) -> None:
if not expr.literal:
return
key = node.literal_hash
key = expr.literal_hash
if key not in self.declarations:
self.declarations[key] = self.get_declaration(node)
self.declarations[key] = self.get_declaration(expr)
self._add_dependencies(key)
self._push(key, typ)

def get(self, expr: Union[Expression, Var]) -> Type:
return self._get(expr.literal_hash)

def cleanse(self, expr: Expression) -> None:
"""Remove all references to a Node from the binder."""
"""Remove all references to an Expression from the binder."""
self._cleanse_key(expr.literal_hash)

def _cleanse_key(self, key: Key) -> None:
Expand Down Expand Up @@ -165,9 +165,9 @@ def pop_frame(self, fall_through: int = 0) -> Frame:

return result

def get_declaration(self, node: Node) -> Type:
if isinstance(node, (RefExpr, SymbolTableNode)) and isinstance(node.node, Var):
type = node.node.type
def get_declaration(self, expr: Expression) -> Type:
if isinstance(expr, (RefExpr, SymbolTableNode)) and isinstance(expr.node, Var):
type = expr.node.type
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test here is never true, and I think the original (changed in one of my previous PRs) was never true either. I wonder why.

if isinstance(type, PartialType):
return None
return type
Expand Down
0