Hello community, here is the log from the commit of package python-astroid for openSUSE:Factory checked in at 2019-11-04 17:13:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-astroid (Old) and /work/SRC/openSUSE:Factory/.python-astroid.new.2990 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-astroid" Mon Nov 4 17:13:51 2019 rev:21 rq:744674 version:2.3.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-astroid/python-astroid.changes 2019-10-10 11:51:10.691682255 +0200 +++ /work/SRC/openSUSE:Factory/.python-astroid.new.2990/python-astroid.changes 2019-11-04 17:13:54.564742068 +0100 @@ -1,0 +2,7 @@ +Fri Nov 1 08:34:46 UTC 2019 - Tomáš Chvátal <tchva...@suse.com> + +- Update to 2.3.2: + * All type comments have as parent the corresponding `astroid` node + * Pass an inference context to `metaclass()` when inferring an object type + +------------------------------------------------------------------- Old: ---- astroid-2.3.1.tar.gz New: ---- astroid-2.3.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-astroid.spec ++++++ --- /var/tmp/diff_new_pack.JF6rTB/_old 2019-11-04 17:13:55.312742867 +0100 +++ /var/tmp/diff_new_pack.JF6rTB/_new 2019-11-04 17:13:55.312742867 +0100 @@ -19,7 +19,7 @@ %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-astroid -Version: 2.3.1 +Version: 2.3.2 Release: 0 Summary: Representation of Python source as an AST for pylint License: LGPL-2.1-or-later ++++++ astroid-2.3.1.tar.gz -> astroid-2.3.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/ChangeLog new/astroid-2.3.2/ChangeLog --- old/astroid-2.3.1/ChangeLog 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/ChangeLog 2019-10-18 11:16:13.000000000 +0200 @@ -2,6 +2,28 @@ astroid's ChangeLog =================== +What's New in astroid 2.3.2? +============================ +Release Date: 2019-10-18 + +* All type comments have as parent the corresponding `astroid` node + + Until now they had as parent the builtin `ast` node which meant + we were operating with primitive objects instead of our own. + + Close PyCQA/pylint#3174 + + +* Pass an inference context to `metaclass()` when inferring an object type + + This should prevent a bunch of recursion errors happening in pylint. + Also refactor the inference of `IfExp` nodes to use separate contexts + for each potential branch. + + Close PyCQA/pylint#3152 + Close PyCQA/pylint#3159 + + What's New in astroid 2.3.1? ============================ Release Date: 2019-09-30 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/PKG-INFO new/astroid-2.3.2/PKG-INFO --- old/astroid-2.3.1/PKG-INFO 2019-09-30 10:06:04.000000000 +0200 +++ new/astroid-2.3.2/PKG-INFO 2019-10-18 11:17:53.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: astroid -Version: 2.3.1 +Version: 2.3.2 Summary: An abstract syntax tree for Python with inference support. Home-page: https://github.com/PyCQA/astroid Author: Python Code Quality Authority diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/__pkginfo__.py new/astroid-2.3.2/astroid/__pkginfo__.py --- old/astroid-2.3.1/astroid/__pkginfo__.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/__pkginfo__.py 2019-10-18 11:16:13.000000000 +0200 @@ -17,7 +17,7 @@ """astroid packaging information""" -version = "2.3.1" +version = "2.3.2" numversion = tuple(int(elem) for elem in version.split(".") if elem.isdigit()) extras_require = {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/bases.py new/astroid-2.3.2/astroid/bases.py --- old/astroid-2.3.1/astroid/bases.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/bases.py 2019-10-18 11:16:13.000000000 +0200 @@ -404,6 +404,7 @@ a subtype of ``type``, the name needs to be a string, the bases needs to be a tuple of classes """ + # pylint: disable=import-outside-toplevel; circular import from astroid import node_classes # Verify the metaclass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/helpers.py new/astroid-2.3.2/astroid/helpers.py --- old/astroid-2.3.1/astroid/helpers.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/helpers.py 2019-10-18 11:16:13.000000000 +0200 @@ -52,7 +52,7 @@ for inferred in node.infer(context=context): if isinstance(inferred, scoped_nodes.ClassDef): if inferred.newstyle: - metaclass = inferred.metaclass() + metaclass = inferred.metaclass(context=context) if metaclass: yield metaclass continue @@ -240,6 +240,7 @@ or if multiple nodes are inferred :rtype int: Integer length of node """ + # pylint: disable=import-outside-toplevel; circular import from astroid.objects import FrozenSet inferred_node = safe_infer(node, context=context) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/inference.py new/astroid-2.3.2/astroid/inference.py --- old/astroid-2.3.1/astroid/inference.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/inference.py 2019-10-18 11:16:13.000000000 +0200 @@ -916,21 +916,28 @@ depending on the condition. """ both_branches = False + # We use two separate contexts for evaluating lhs and rhs because + # evaluating lhs may leave some undesired entries in context.path + # which may not let us infer right value of rhs. + + context = context or contextmod.InferenceContext() + lhs_context = contextmod.copy_context(context) + rhs_context = contextmod.copy_context(context) try: - test = next(self.test.infer(context=context)) + test = next(self.test.infer(context=context.clone())) except exceptions.InferenceError: both_branches = True else: if test is not util.Uninferable: if test.bool_value(): - yield from self.body.infer(context=context) + yield from self.body.infer(context=lhs_context) else: - yield from self.orelse.infer(context=context) + yield from self.orelse.infer(context=rhs_context) else: both_branches = True if both_branches: - yield from self.body.infer(context=context) - yield from self.orelse.infer(context=context) + yield from self.body.infer(context=lhs_context) + yield from self.orelse.infer(context=rhs_context) nodes.IfExp._infer = infer_ifexp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/interpreter/objectmodel.py new/astroid-2.3.2/astroid/interpreter/objectmodel.py --- old/astroid-2.3.1/astroid/interpreter/objectmodel.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/interpreter/objectmodel.py 2019-10-18 11:16:13.000000000 +0200 @@ -280,6 +280,7 @@ @property def attr___get__(self): + # pylint: disable=import-outside-toplevel; circular import from astroid import bases func = self._instance @@ -425,6 +426,7 @@ target=self._instance, attribute="mro" ) + # pylint: disable=import-outside-toplevel; circular import from astroid import bases other_self = self @@ -449,6 +451,7 @@ @property def attr___class__(self): + # pylint: disable=import-outside-toplevel; circular import from astroid import helpers return helpers.object_type(self._instance) @@ -460,6 +463,7 @@ This looks only in the current module for retrieving the subclasses, thus it might miss a couple of them. """ + # pylint: disable=import-outside-toplevel; circular import from astroid import bases from astroid import scoped_nodes @@ -513,6 +517,7 @@ class UnboundMethodModel(ObjectModel): @property def attr___class__(self): + # pylint: disable=import-outside-toplevel; circular import from astroid import helpers return helpers.object_type(self._instance) @@ -701,10 +706,10 @@ elems.append(elem) obj.postinit(elts=elems) + # pylint: disable=import-outside-toplevel; circular import from astroid import objects obj = objects.DictItems(obj) - return self._generic_dict_attribute(obj, "items") @property @@ -713,10 +718,10 @@ obj = node_classes.List(parent=self._instance) obj.postinit(elts=keys) + # pylint: disable=import-outside-toplevel; circular import from astroid import objects obj = objects.DictKeys(obj) - return self._generic_dict_attribute(obj, "keys") @property @@ -726,8 +731,8 @@ obj = node_classes.List(parent=self._instance) obj.postinit(values) + # pylint: disable=import-outside-toplevel; circular import from astroid import objects obj = objects.DictValues(obj) - return self._generic_dict_attribute(obj, "values") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/manager.py new/astroid-2.3.2/astroid/manager.py --- old/astroid-2.3.1/astroid/manager.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/manager.py 2019-10-18 11:16:13.000000000 +0200 @@ -89,6 +89,7 @@ ): return self.astroid_cache[modname] if source: + # pylint: disable=import-outside-toplevel; circular import from astroid.builder import AstroidBuilder return AstroidBuilder(self).file_build(filepath, modname) @@ -99,11 +100,13 @@ ) def _build_stub_module(self, modname): + # pylint: disable=import-outside-toplevel; circular import from astroid.builder import AstroidBuilder return AstroidBuilder(self).string_build("", modname) def _build_namespace_module(self, modname, path): + # pylint: disable=import-outside-toplevel; circular import from astroid.builder import build_namespace_package_module return build_namespace_package_module(modname, path) @@ -185,6 +188,8 @@ def zip_import_data(self, filepath): if zipimport is None: return None + + # pylint: disable=import-outside-toplevel; circular import from astroid.builder import AstroidBuilder builder = AstroidBuilder(self) @@ -237,6 +242,8 @@ return self.ast_from_file(filepath, modname) except AttributeError: pass + + # pylint: disable=import-outside-toplevel; circular import from astroid.builder import AstroidBuilder return AstroidBuilder(self).module_build(module, modname) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/node_classes.py new/astroid-2.3.2/astroid/node_classes.py --- old/astroid-2.3.1/astroid/node_classes.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/node_classes.py 2019-10-18 11:16:13.000000000 +0200 @@ -496,7 +496,9 @@ :returns: The first parent scope node. :rtype: Module or FunctionDef or ClassDef or Lambda or GenExpr """ - return self.parent.scope() + if self.parent: + return self.parent.scope() + return None def root(self): """Return the root node of the syntax tree. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/rebuilder.py new/astroid-2.3.2/astroid/rebuilder.py --- old/astroid-2.3.1/astroid/rebuilder.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/rebuilder.py 2019-10-18 11:16:13.000000000 +0200 @@ -218,7 +218,9 @@ self.visit(arg.annotation, newnode) if arg.annotation else None for arg in node.posonlyargs ] - type_comment_args = [self.check_type_comment(child) for child in node.args] + type_comment_args = [ + self.check_type_comment(child, parent=newnode) for child in node.args + ] newnode.postinit( args=args, @@ -250,7 +252,7 @@ newnode.postinit(self.visit(node.test, newnode), msg) return newnode - def check_type_comment(self, node): + def check_type_comment(self, node, parent): type_comment = getattr(node, "type_comment", None) if not type_comment: return None @@ -261,7 +263,7 @@ # Invalid type comment, just skip it. return None - type_object = self.visit(type_comment_ast.body[0], node) + type_object = self.visit(type_comment_ast.body[0], parent=parent) if not isinstance(type_object, nodes.Expr): return None @@ -289,8 +291,8 @@ def visit_assign(self, node, parent): """visit a Assign node by returning a fresh instance of it""" - type_annotation = self.check_type_comment(node) newnode = nodes.Assign(node.lineno, node.col_offset, parent) + type_annotation = self.check_type_comment(node, parent=newnode) newnode.postinit( targets=[self.visit(child, newnode) for child in node.targets], value=self.visit(node.value, newnode), @@ -550,7 +552,7 @@ def _visit_for(self, cls, node, parent): """visit a For node by returning a fresh instance of it""" newnode = cls(node.lineno, node.col_offset, parent) - type_annotation = self.check_type_comment(node) + type_annotation = self.check_type_comment(node, parent=newnode) newnode.postinit( target=self.visit(node.target, newnode), iter=self.visit(node.iter, newnode), @@ -912,7 +914,7 @@ else: optional_vars = None - type_annotation = self.check_type_comment(node) + type_annotation = self.check_type_comment(node, parent=newnode) newnode.postinit( items=[(expr, optional_vars)], body=[self.visit(child, newnode) for child in node.body], @@ -1026,7 +1028,7 @@ var = _visit_or_none(child, "optional_vars", self, newnode) return expr, var - type_annotation = self.check_type_comment(node) + type_annotation = self.check_type_comment(node, parent=newnode) newnode.postinit( items=[visit_child(child) for child in node.items], body=[self.visit(child, newnode) for child in node.body], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/tests/unittest_builder.py new/astroid-2.3.2/astroid/tests/unittest_builder.py --- old/astroid-2.3.1/astroid/tests/unittest_builder.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/tests/unittest_builder.py 2019-10-18 11:16:13.000000000 +0200 @@ -302,21 +302,6 @@ self.assertTrue(time_ast) self.assertEqual(time_ast["time"].args.defaults, []) - if os.name == "java": - test_inspect_build1 = unittest.expectedFailure(test_inspect_build1) - - def test_inspect_build2(self): - """test astroid tree build from a living object""" - try: - from mx import DateTime - except ImportError: - self.skipTest("test skipped: mxDateTime is not available") - else: - dt_ast = self.builder.inspect_build(DateTime) - dt_ast.getattr("DateTime") - # this one is failing since DateTimeType.__module__ = 'builtins' ! - # dt_ast.getattr('DateTimeType') - def test_inspect_build3(self): self.builder.inspect_build(unittest) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid/tests/unittest_nodes.py new/astroid-2.3.2/astroid/tests/unittest_nodes.py --- old/astroid-2.3.1/astroid/tests/unittest_nodes.py 2019-09-30 10:04:18.000000000 +0200 +++ new/astroid-2.3.2/astroid/tests/unittest_nodes.py 2019-10-18 11:16:13.000000000 +0200 @@ -1195,5 +1195,26 @@ assert node.as_string() == "f'3={3}'" +@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") +def test_parse_type_comments_with_proper_parent(): + code = """ + class D: #@ + @staticmethod + def g( + x # type: np.array + ): + pass + """ + node = astroid.extract_node(code) + func = node.getattr("g")[0] + type_comments = func.args.type_comment_args + assert len(type_comments) == 1 + + type_comment = type_comments[0] + assert isinstance(type_comment, astroid.Attribute) + assert isinstance(type_comment.parent, astroid.Expr) + assert isinstance(type_comment.parent.parent, astroid.Arguments) + + if __name__ == "__main__": unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/astroid-2.3.1/astroid.egg-info/PKG-INFO new/astroid-2.3.2/astroid.egg-info/PKG-INFO --- old/astroid-2.3.1/astroid.egg-info/PKG-INFO 2019-09-30 10:06:04.000000000 +0200 +++ new/astroid-2.3.2/astroid.egg-info/PKG-INFO 2019-10-18 11:17:53.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: astroid -Version: 2.3.1 +Version: 2.3.2 Summary: An abstract syntax tree for Python with inference support. Home-page: https://github.com/PyCQA/astroid Author: Python Code Quality Authority