summaryrefslogtreecommitdiff
path: root/astroid/node_classes.py
diff options
context:
space:
mode:
authorCeridwen <ceridwenv@gmail.com>2015-09-13 16:33:14 -0400
committerCeridwen <ceridwenv@gmail.com>2015-09-13 16:33:14 -0400
commitfe1e66536cb674a769a92ac9995b8961273e6852 (patch)
treeff64512150af1c04d58471ca48adb1bc123b73f6 /astroid/node_classes.py
parent177006d2c3db616e7cc4cb9cc00699d8519109c0 (diff)
parent052c63b2ea0a53d0486056c72eb2bca0d64a8ea5 (diff)
downloadastroid-fe1e66536cb674a769a92ac9995b8961273e6852.tar.gz
Final draft of state printing after merge
This patch adds __str__` and `__repr__` methods to InferenceContext and alters the `__str__, `__repr__, and repr_tree() methods for NodeNG. The `__str__` methods print out formatted information about the object's fields; NodeNG's `__str__` method is not recursive. InferenceContext's __repr__` gives a compact representation of its fields. I slightly shortened NodeNG's `__repr__` method by removing a field that's usually empty. I rewrote repr_tree() to better format the information it contains and to display *all* the fields for each AST node, with some fields controlled by options to avoid spam. I also fixed https://bitbucket.org/logilab/astroid/issues/185/as_string-gives-wrong-result-for-keyword .
Diffstat (limited to 'astroid/node_classes.py')
-rw-r--r--astroid/node_classes.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/astroid/node_classes.py b/astroid/node_classes.py
index 1efd139..524cb4e 100644
--- a/astroid/node_classes.py
+++ b/astroid/node_classes.py
@@ -392,8 +392,8 @@ class Arguments(mixins.AssignTypeMixin, bases.NodeNG):
result = []
if self.args:
result.append(
- _format_args(self.args, getattr(self, 'annotations', None),
- self.defaults)
+ _format_args(self.args, self.defaults,
+ getattr(self, 'annotations', None))
)
if self.vararg:
result.append('*%s' % self.vararg)
@@ -453,7 +453,7 @@ def _find_arg(argname, args, rec=False):
return None, None
-def _format_args(args, annotations=None, defaults=None):
+def _format_args(args, defaults=None, annotations=None):
values = []
if args is None:
return ''
@@ -932,7 +932,7 @@ class ImportFrom(mixins.ImportFromMixin, bases.Statement):
class Attribute(bases.NodeNG):
"""class representing a Attribute node"""
_astroid_fields = ('expr',)
- _other_fields = ('attrname')
+ _other_fields = ('attrname',)
expr = None
def __init__(self, attrname=None, lineno=None, col_offset=None, parent=None):