From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8AE9A1382C5 for ; Tue, 6 Apr 2021 07:22:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BB987E08F3; Tue, 6 Apr 2021 07:22:52 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 848B0E08F3 for ; Tue, 6 Apr 2021 07:22:52 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 79FFC340D5A for ; Tue, 6 Apr 2021 07:22:51 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EA41E66A for ; Tue, 6 Apr 2021 07:22:47 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1617693763.ed3b0f3f4a19ebdb1d0fea0e60fcf6f262e3c111.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/rope/, dev-python/rope/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-python/rope/files/rope-0.18.0-add-python-3.9-support.patch dev-python/rope/rope-0.18.0-r1.ebuild X-VCS-Directories: dev-python/rope/ dev-python/rope/files/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: ed3b0f3f4a19ebdb1d0fea0e60fcf6f262e3c111 X-VCS-Branch: master Date: Tue, 6 Apr 2021 07:22:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: ee3b8662-51fd-4f64-bef1-90d3b771207b X-Archives-Hash: 246bc359b38a148a0e19cda7ab67b4c4 commit: ed3b0f3f4a19ebdb1d0fea0e60fcf6f262e3c111 Author: Matt Turner gentoo org> AuthorDate: Mon Apr 5 22:44:04 2021 +0000 Commit: Michał Górny gentoo org> CommitDate: Tue Apr 6 07:22:43 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ed3b0f3f dev-python/rope: Add Python 3.9 support Signed-off-by: Matt Turner gentoo.org> Closes: https://github.com/gentoo/gentoo/pull/20272 Signed-off-by: Michał Górny gentoo.org> .../files/rope-0.18.0-add-python-3.9-support.patch | 155 +++++++++++++++++++++ dev-python/rope/rope-0.18.0-r1.ebuild | 45 ++++++ 2 files changed, 200 insertions(+) diff --git a/dev-python/rope/files/rope-0.18.0-add-python-3.9-support.patch b/dev-python/rope/files/rope-0.18.0-add-python-3.9-support.patch new file mode 100644 index 00000000000..edb5304841d --- /dev/null +++ b/dev-python/rope/files/rope-0.18.0-add-python-3.9-support.patch @@ -0,0 +1,155 @@ +https://github.com/python-rope/rope/pull/333 + +From a63ae26035c5493dc8b7c3bf6a70fc05dba2be98 Mon Sep 17 00:00:00 2001 +From: Matt Turner +Date: Sun, 14 Mar 2021 10:17:47 -0400 +Subject: [PATCH 1/3] Fix test expectations for Python 3.9 AST changes + +Fixes the following two tests under Python 3.9: + +FAILED ropetest/refactor/patchedasttest.py::PatchedASTTest::test_ext_slice_node - AssertionError: Node cannot be found +FAILED ropetest/refactor/patchedasttest.py::PatchedASTTest::test_simple_subscript - AssertionError: False is not true : Expected but was + +The ast module in Python 3.9 has some API changes. Quoting [1]: + + Simplified AST for subscription. Simple indices will be represented + by their value, extended slices will be represented as tuples. + Index(value) will return a value itself, ExtSlice(slices) will + return Tuple(slices, Load()). (Contributed by Serhiy Storchaka in + bpo-34822.) + +[1] https://docs.python.org/3/whatsnew/3.9.html#changes-in-the-python-api +--- + ropetest/refactor/patchedasttest.py | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/ropetest/refactor/patchedasttest.py b/ropetest/refactor/patchedasttest.py +index 04df3752..74a9d9a6 100644 +--- a/ropetest/refactor/patchedasttest.py ++++ b/ropetest/refactor/patchedasttest.py +@@ -838,8 +838,12 @@ class PatchedASTTest(unittest.TestCase): + source = 'x = xs[0,:]\n' + ast_frag = patchedast.get_patched_ast(source, True) + checker = _ResultChecker(self, ast_frag) +- checker.check_region('ExtSlice', 7, len(source) - 2) +- checker.check_children('ExtSlice', ['Index', '', ',', '', 'Slice']) ++ if sys.version_info >= (3, 9): ++ checker.check_region('Tuple', 7, len(source) - 2) ++ checker.check_children('Tuple', ['Num', '', ',', '', 'Slice']) ++ else: ++ checker.check_region('ExtSlice', 7, len(source) - 2) ++ checker.check_children('ExtSlice', ['Index', '', ',', '', 'Slice']) + + def test_simple_module_node(self): + source = 'pass\n' +@@ -933,9 +937,13 @@ class PatchedASTTest(unittest.TestCase): + source = 'a[1]\n' + ast_frag = patchedast.get_patched_ast(source, True) + checker = _ResultChecker(self, ast_frag) +- checker.check_children( +- 'Subscript', ['Name', '', '[', '', 'Index', '', ']']) +- checker.check_children('Index', ['Num']) ++ if sys.version_info >= (3, 9): ++ checker.check_children( ++ 'Subscript', ['Name', '', '[', '', 'Num', '', ']']) ++ else: ++ checker.check_children( ++ 'Subscript', ['Name', '', '[', '', 'Index', '', ']']) ++ checker.check_children('Index', ['Num']) + + def test_tuple_node(self): + source = '(1, 2)\n' +-- +2.26.2 + +From 02284e4151c2b1d549a64175ef0e3212b7737c56 Mon Sep 17 00:00:00 2001 +From: Matt Turner +Date: Sun, 14 Mar 2021 10:54:48 -0400 +Subject: [PATCH 2/3] Handle AST.expr in _Subscript() + +The ast module in Python 3.9 has some API changes. Quoting [1]: + + Simplified AST for subscription. Simple indices will be represented + by their value, extended slices will be represented as tuples. + Index(value) will return a value itself, ExtSlice(slices) will + return Tuple(slices, Load()). (Contributed by Serhiy Storchaka in + bpo-34822.) + +[1] https://docs.python.org/3/whatsnew/3.9.html#changes-in-the-python-api + +isinstance(thing, ast.Index) always return false in Python >= 3.9, so we +need to handle... whatever the value is now. ast.expr catches 20 of the +remaining 24 failures. The remaining 4 are resolved in the next patch. + +Fixes: #299 +--- + rope/base/evaluate.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/rope/base/evaluate.py b/rope/base/evaluate.py +index 610d34e0..4634981a 100644 +--- a/rope/base/evaluate.py ++++ b/rope/base/evaluate.py +@@ -307,6 +307,9 @@ class StatementEvaluator(object): + elif isinstance(node.slice, ast.Slice): + self._call_function(node.value, '__getitem__', + [node.slice]) ++ elif isinstance(node.slice, ast.expr): ++ self._call_function(node.value, '__getitem__', ++ [node.value]) + + def _Slice(self, node): + self.result = self._get_builtin_name('slice') +-- +2.26.2 + +From 46a3403a06aaadf9d17f87b38300c4e3febe47c5 Mon Sep 17 00:00:00 2001 +From: Matt Turner +Date: Fri, 19 Mar 2021 18:41:53 -0400 +Subject: [PATCH 3/3] Handle AST.expr in static object analysis + +The ast module in Python 3.9 has some API changes. Quoting [1]: + + Simplified AST for subscription. Simple indices will be represented + by their value, extended slices will be represented as tuples. + Index(value) will return a value itself, ExtSlice(slices) will + return Tuple(slices, Load()). (Contributed by Serhiy Storchaka in + bpo-34822.) + +[1] https://docs.python.org/3/whatsnew/3.9.html#changes-in-the-python-api + +This fixes the remaining 4 failures under Python 3.9. + +FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_append_function +FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_for_loops +FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_update +FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_lists_per_object_for_set_item + +Fixes: #299 +--- + rope/base/oi/soa.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/rope/base/oi/soa.py b/rope/base/oi/soa.py +index 8ef17aee..20ab567e 100644 +--- a/rope/base/oi/soa.py ++++ b/rope/base/oi/soa.py +@@ -126,7 +126,7 @@ class SOAVisitor(object): + for subscript, levels in nodes: + instance = evaluate.eval_node(self.scope, subscript.value) + args_pynames = [evaluate.eval_node(self.scope, +- subscript.slice.value)] ++ subscript.slice)] + value = rope.base.oi.soi._infer_assignment( + rope.base.pynames.AssignmentValue(node.value, levels, + type_hint=type_hint), +@@ -149,5 +149,5 @@ class _SOAAssignVisitor(astutils._NodeNameCollector): + + def _added(self, node, levels): + if isinstance(node, rope.base.ast.Subscript) and \ +- isinstance(node.slice, rope.base.ast.Index): ++ isinstance(node.slice, (rope.base.ast.Index, rope.base.ast.expr)): + self.nodes.append((node, levels)) +-- +2.26.2 + diff --git a/dev-python/rope/rope-0.18.0-r1.ebuild b/dev-python/rope/rope-0.18.0-r1.ebuild new file mode 100644 index 00000000000..30b91ee55c4 --- /dev/null +++ b/dev-python/rope/rope-0.18.0-r1.ebuild @@ -0,0 +1,45 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{7..9} ) + +inherit distutils-r1 + +DESCRIPTION="Python refactoring library" +HOMEPAGE="https://github.com/python-rope/rope" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +LICENSE="LGPL-3" +SLOT="0" +KEYWORDS="~amd64 ~arm64 ~x86 ~amd64-linux ~x86-linux" + +IUSE="doc" + +# Dependency for docbuild documentation which is not noted in +# setup.py, using standard docutils builds docs successfully. +DEPEND="doc? ( dev-python/docutils[${PYTHON_USEDEP}] )" + +PATCHES=( + "${FILESDIR}"/${P}-add-python-3.9-support.patch +) + +distutils_enable_tests pytest + +python_compile_all() { + if use doc; then + pushd docs > /dev/null || die + mkdir build || die + local i + for i in ./*.rst; do + rst2html.py $i > ./build/${i/rst/html} || die + done + popd > /dev/null || die + fi +} + +python_install_all() { + use doc && local HTML_DOCS=( docs/build/. ) + distutils-r1_python_install_all +}