Skip to content

Move visit_var to NodeVisitor (from StatementVisitor) #6547

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

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ def name(self) -> str:
def fullname(self) -> Bogus[str]:
return self._fullname

def accept(self, visitor: StatementVisitor[T]) -> T:
def accept(self, visitor: NodeVisitor[T]) -> T:
return visitor.visit_var(self)

def serialize(self) -> JsonDict:
Expand Down
13 changes: 6 additions & 7 deletions mypy/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ def visit_nonlocal_decl(self, o: 'mypy.nodes.NonlocalDecl') -> T:
def visit_decorator(self, o: 'mypy.nodes.Decorator') -> T:
pass

@abstractmethod
def visit_var(self, o: 'mypy.nodes.Var') -> T:
pass

# Module structure

@abstractmethod
Expand Down Expand Up @@ -320,6 +316,12 @@ class NodeVisitor(Generic[T], ExpressionVisitor[T], StatementVisitor[T]):
def visit_mypy_file(self, o: 'mypy.nodes.MypyFile') -> T:
pass

# TODO: We have a visit_var method, but no visit_typeinfo or any
# other non-Statement SymbolNode (accepting those will raise a
# runtime error). Maybe this should be resolved in some direction.
def visit_var(self, o: 'mypy.nodes.Var') -> T:
pass

# Module structure

def visit_import(self, o: 'mypy.nodes.Import') -> T:
Expand Down Expand Up @@ -352,9 +354,6 @@ def visit_nonlocal_decl(self, o: 'mypy.nodes.NonlocalDecl') -> T:
def visit_decorator(self, o: 'mypy.nodes.Decorator') -> T:
pass

def visit_var(self, o: 'mypy.nodes.Var') -> T:
pass

def visit_type_alias(self, o: 'mypy.nodes.TypeAlias') -> T:
pass

Expand Down