diff options
-rw-r--r-- | astroid/as_string.py | 2 | ||||
-rw-r--r-- | astroid/bases.py | 4 | ||||
-rw-r--r-- | astroid/context.py | 2 | ||||
-rw-r--r-- | astroid/rebuilder.py | 2 | ||||
-rw-r--r-- | astroid/tests/unittest_inference.py | 38 | ||||
-rw-r--r-- | astroid/tests/unittest_nodes.py | 3 | ||||
-rw-r--r-- | pylintrc | 2 |
7 files changed, 27 insertions, 26 deletions
diff --git a/astroid/as_string.py b/astroid/as_string.py index ee1a143c..20f49368 100644 --- a/astroid/as_string.py +++ b/astroid/as_string.py @@ -467,7 +467,7 @@ class AsStringVisitor3(AsStringVisitor): def visit_await(self, node): return 'await %s' % node.value.accept(self) - + def visit_asyncwith(self, node): return 'async %s' % self.visit_with(node) diff --git a/astroid/bases.py b/astroid/bases.py index 784fe9e7..4378f4a8 100644 --- a/astroid/bases.py +++ b/astroid/bases.py @@ -788,7 +788,7 @@ class NodeNG(object): def repr_tree(self, ids=False, include_linenos=False, ast_state=False, indent=' ', max_depth=0, max_width=80): - """Returns a string representation of the AST from this node. + """Returns a string representation of the AST from this node. :param ids: If true, includes the ids with the node type names. @@ -820,6 +820,7 @@ class NodeNG(object): result.extend([cur_indent + line for line in lines[1:]]) return len(lines) != 1 + # pylint: disable=unused-variable; doesn't understand singledispatch @_repr_tree.register(tuple) @_repr_tree.register(list) def _repr_seq(node, result, done, cur_indent='', depth=1): @@ -851,6 +852,7 @@ class NodeNG(object): result.append(']') return broken + # pylint: disable=unused-variable; doesn't understand singledispatch @_repr_tree.register(NodeNG) def _repr_node(node, result, done, cur_indent='', depth=1): """Outputs a strings representation of an astroid node.""" diff --git a/astroid/context.py b/astroid/context.py index 051fab81..ecaa1ba0 100644 --- a/astroid/context.py +++ b/astroid/context.py @@ -66,7 +66,7 @@ class InferenceContext(object): width=80 - len(field))) for field in self.__slots__) return '%s(%s)' % (type(self).__name__, ',\n '.join(state)) - + def __repr__(self): state = ('%s=%s' % (field, repr(getattr(self, field))) for field in self.__slots__) diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py index 29015fb1..7ea9cf26 100644 --- a/astroid/rebuilder.py +++ b/astroid/rebuilder.py @@ -312,7 +312,7 @@ class TreeRebuilder(object): keywords.append(new_kwargs) else: keywords = [new_kwargs] - + newnode.postinit(self.visit(node.func, newnode, assign_ctx), args, keywords) return newnode diff --git a/astroid/tests/unittest_inference.py b/astroid/tests/unittest_inference.py index ef0886f4..6af41f18 100644 --- a/astroid/tests/unittest_inference.py +++ b/astroid/tests/unittest_inference.py @@ -2941,27 +2941,27 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase): def test_function_metaclasses(self): # These are not supported right now, although # they will be in the future. - ast_node = test_utils.extract_node(''' - import six + ast_node = test_utils.extract_node(''' + import six - class BookMeta(type): - author = 'Rushdie' + class BookMeta(type): + author = 'Rushdie' - def metaclass_function(*args): - return BookMeta + def metaclass_function(*args): + return BookMeta - @six.add_metaclass(metaclass_function) - class Book(object): - pass - Book #@ - ''') - inferred = next(ast_node.infer()) - metaclass = inferred.metaclass() - self.assertIsInstance(metaclass, nodes.ClassDef) - self.assertEqual(metaclass.name, 'BookMeta') - author = next(inferred.igetattr('author')) - self.assertIsInstance(author, nodes.Const) - self.assertEqual(author.value, 'Rushdie') + @six.add_metaclass(metaclass_function) + class Book(object): + pass + Book #@ + ''') + inferred = next(ast_node.infer()) + metaclass = inferred.metaclass() + self.assertIsInstance(metaclass, nodes.ClassDef) + self.assertEqual(metaclass.name, 'BookMeta') + author = next(inferred.igetattr('author')) + self.assertIsInstance(author, nodes.Const) + self.assertEqual(author.value, 'Rushdie') def test_subscript_inference_error(self): # Used to raise StopIteration @@ -3577,7 +3577,7 @@ class SliceTest(unittest.TestCase): ''') for node in ast_nodes: self.assertRaises(InferenceError, next, node.infer()) - + if __name__ == '__main__': unittest.main() diff --git a/astroid/tests/unittest_nodes.py b/astroid/tests/unittest_nodes.py index 590359e3..eb210736 100644 --- a/astroid/tests/unittest_nodes.py +++ b/astroid/tests/unittest_nodes.py @@ -695,7 +695,7 @@ class DeprecationWarningsTest(unittest.TestCase): @test_utils.require_version('3.5') class Python35AsyncTest(unittest.TestCase): - + def test_async_await_keywords(self): async_def, async_for, async_with, await_node = test_utils.extract_node(''' async def func(): #@ @@ -736,7 +736,6 @@ class Python35AsyncTest(unittest.TestCase): await 42 ''') self._test_await_async_as_string(code) - if __name__ == '__main__': @@ -329,7 +329,7 @@ max-branches=12 max-statements=50
# Maximum number of parents for a class (see R0901).
-max-parents=7
+max-parents=10
# Maximum number of attributes for a class (see R0902).
max-attributes=7
|