Skip to content
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

Remove postinit #2

Merged
merged 4 commits into from
May 3, 2016
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
22 changes: 14 additions & 8 deletions astroid/as_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,13 @@ def visit_yield(self, node):
"""yield an ast.Yield node as string"""
yi_val = node.value and (" " + node.value.accept(self)) or ""
expr = 'yield' + yi_val
if node.parent.is_statement:
return expr
else:
return "(%s)" % (expr,)
# TODO: this code can be restored when the as_string() visitor
# is made to work with the zipper.

# if node.parent.is_statement:
# return expr
# else:
return "(%s)" % (expr,)

def visit_starred(self, node):
"""return Starred node as string"""
Expand Down Expand Up @@ -453,10 +456,13 @@ def visit_yieldfrom(self, node):
""" Return an astroid.YieldFrom node as string. """
yi_val = node.value and (" " + node.value.accept(self)) or ""
expr = 'yield from' + yi_val
if node.parent.is_statement:
return expr
else:
return "(%s)" % (expr,)
# TODO: this code can be restored when the as_string() visitor
# is made to work with the zipper.

# if node.parent.is_statement:
# return expr
# else:
return "(%s)" % (expr,)

def visit_asyncfunctiondef(self, node):
function = super(AsStringVisitor3, self).visit_functiondef(node)
Expand Down
3 changes: 1 addition & 2 deletions astroid/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ class BaseNode(object):
# instance specific inference function infer(node, context)
_explicit_inference = None

def __init__(self, lineno=None, col_offset=None, parent=None):
def __init__(self, lineno=None, col_offset=None):
self.lineno = lineno
self.col_offset = col_offset
self.parent = parent

def __iter__(self):
for field in self._astroid_fields:
Expand Down
Loading