1 |
commit: 59aaf1df5546e712d455f0113692e6447b5c6f56 |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Feb 17 15:22:29 2020 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Feb 17 15:55:43 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59aaf1df |
7 |
|
8 |
dev-python/rope: Fix test execution with python3.7 |
9 |
|
10 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
11 |
|
12 |
dev-python/rope/files/rope-0.16.0-python3.7.patch | 251 ++++++++++++++++++++++ |
13 |
dev-python/rope/rope-0.16.0.ebuild | 10 +- |
14 |
2 files changed, 257 insertions(+), 4 deletions(-) |
15 |
|
16 |
diff --git a/dev-python/rope/files/rope-0.16.0-python3.7.patch b/dev-python/rope/files/rope-0.16.0-python3.7.patch |
17 |
new file mode 100644 |
18 |
index 00000000000..d120a8ecc51 |
19 |
--- /dev/null |
20 |
+++ b/dev-python/rope/files/rope-0.16.0-python3.7.patch |
21 |
@@ -0,0 +1,251 @@ |
22 |
+From 5c38f7c8ba23813b475dcb24fa66ed3fc52d1658 Mon Sep 17 00:00:00 2001 |
23 |
+From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@××××.eu> |
24 |
+Date: Mon, 13 Jan 2020 15:07:46 +0100 |
25 |
+Subject: [PATCH 1/4] Use .is_alive method instead of a deprecated .isAlive in |
26 |
+ threading.Thread |
27 |
+ |
28 |
+--- |
29 |
+ ropetest/type_hinting_test.py | 8 ++++---- |
30 |
+ 1 file changed, 4 insertions(+), 4 deletions(-) |
31 |
+ |
32 |
+diff --git a/ropetest/type_hinting_test.py b/ropetest/type_hinting_test.py |
33 |
+index 7cc02bb1..afb98e19 100644 |
34 |
+--- a/ropetest/type_hinting_test.py |
35 |
++++ b/ropetest/type_hinting_test.py |
36 |
+@@ -198,18 +198,18 @@ def test_hint_parametrized_iterable(self): |
37 |
+ + self._make_class_hint('collections.Iterable[threading.Thread]') + \ |
38 |
+ ' def a_method(self):\n' \ |
39 |
+ ' for i in self.a_attr:\n' \ |
40 |
+- ' i.isA' |
41 |
++ ' i.is_a' |
42 |
+ result = self._assist(code) |
43 |
+- self.assert_completion_in_result('isAlive', 'attribute', result) |
44 |
++ self.assert_completion_in_result('is_alive', 'attribute', result) |
45 |
+ |
46 |
+ def test_hint_parametrized_iterator(self): |
47 |
+ code = 'class Sample(object):\n' \ |
48 |
+ + self._make_class_hint('collections.Iterator[threading.Thread]') + \ |
49 |
+ ' def a_method(self):\n' \ |
50 |
+ ' for i in self.a_attr:\n' \ |
51 |
+- ' i.isA' |
52 |
++ ' i.is_a' |
53 |
+ result = self._assist(code) |
54 |
+- self.assert_completion_in_result('isAlive', 'attribute', result) |
55 |
++ self.assert_completion_in_result('is_alive', 'attribute', result) |
56 |
+ |
57 |
+ def test_hint_parametrized_dict_key(self): |
58 |
+ code = 'class Sample(object):\n' \ |
59 |
+ |
60 |
+From df3567f2afac8b5c5b50f8b7a01e21259e397f81 Mon Sep 17 00:00:00 2001 |
61 |
+From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@××××.eu> |
62 |
+Date: Mon, 13 Jan 2020 15:29:14 +0100 |
63 |
+Subject: [PATCH 2/4] Direct import from collections is getting deprecated. |
64 |
+ |
65 |
+--- |
66 |
+ rope/base/utils/datastructures.py | 7 +++++-- |
67 |
+ 1 file changed, 5 insertions(+), 2 deletions(-) |
68 |
+ |
69 |
+diff --git a/rope/base/utils/datastructures.py b/rope/base/utils/datastructures.py |
70 |
+index 0cb16cf2..3790a6e1 100644 |
71 |
+--- a/rope/base/utils/datastructures.py |
72 |
++++ b/rope/base/utils/datastructures.py |
73 |
+@@ -1,10 +1,13 @@ |
74 |
+ # this snippet was taken from this link |
75 |
+ # http://code.activestate.com/recipes/576694/ |
76 |
+ |
77 |
+-import collections |
78 |
++try: |
79 |
++ from collections import MutableSet |
80 |
++except ImportError: |
81 |
++ from collections.abc import MutableSet |
82 |
+ |
83 |
+ |
84 |
+-class OrderedSet(collections.MutableSet): |
85 |
++class OrderedSet(MutableSet): |
86 |
+ |
87 |
+ def __init__(self, iterable=None): |
88 |
+ self.end = end = [] |
89 |
+ |
90 |
+From fa5626ea99a6cac4780184d708108a98bd7e6095 Mon Sep 17 00:00:00 2001 |
91 |
+From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@××××.eu> |
92 |
+Date: Mon, 13 Jan 2020 16:36:01 +0100 |
93 |
+Subject: [PATCH 3/4] Don't use underscored _ast, but use ast instead |
94 |
+ |
95 |
+--- |
96 |
+ rope/base/ast.py | 15 ++++++++------- |
97 |
+ rope/base/utils/pycompat.py | 6 +++--- |
98 |
+ 2 files changed, 11 insertions(+), 10 deletions(-) |
99 |
+ |
100 |
+diff --git a/rope/base/ast.py b/rope/base/ast.py |
101 |
+index d43c83c5..d24524e7 100644 |
102 |
+--- a/rope/base/ast.py |
103 |
++++ b/rope/base/ast.py |
104 |
+@@ -1,5 +1,6 @@ |
105 |
+-import _ast |
106 |
+-from _ast import * |
107 |
++from __future__ import absolute_import |
108 |
++import ast |
109 |
++from ast import * |
110 |
+ |
111 |
+ from rope.base import fscommands |
112 |
+ |
113 |
+@@ -18,7 +19,7 @@ def parse(source, filename='<string>'): |
114 |
+ if not source.endswith(b'\n'): |
115 |
+ source += b'\n' |
116 |
+ try: |
117 |
+- return compile(source, filename, 'exec', _ast.PyCF_ONLY_AST) |
118 |
++ return ast.parse(source, filename='<unknown>') |
119 |
+ except (TypeError, ValueError) as e: |
120 |
+ error = SyntaxError() |
121 |
+ error.lineno = 1 |
122 |
+@@ -32,7 +33,7 @@ def walk(node, walker): |
123 |
+ method_name = '_' + node.__class__.__name__ |
124 |
+ method = getattr(walker, method_name, None) |
125 |
+ if method is not None: |
126 |
+- if isinstance(node, _ast.ImportFrom) and node.module is None: |
127 |
++ if isinstance(node, ast.ImportFrom) and node.module is None: |
128 |
+ # In python < 2.7 ``node.module == ''`` for relative imports |
129 |
+ # but for python 2.7 it is None. Generalizing it to ''. |
130 |
+ node.module = '' |
131 |
+@@ -42,7 +43,7 @@ def walk(node, walker): |
132 |
+ |
133 |
+ |
134 |
+ def get_child_nodes(node): |
135 |
+- if isinstance(node, _ast.Module): |
136 |
++ if isinstance(node, ast.Module): |
137 |
+ return node.body |
138 |
+ result = [] |
139 |
+ if node._fields is not None: |
140 |
+@@ -50,9 +51,9 @@ def get_child_nodes(node): |
141 |
+ child = getattr(node, name) |
142 |
+ if isinstance(child, list): |
143 |
+ for entry in child: |
144 |
+- if isinstance(entry, _ast.AST): |
145 |
++ if isinstance(entry, ast.AST): |
146 |
+ result.append(entry) |
147 |
+- if isinstance(child, _ast.AST): |
148 |
++ if isinstance(child, ast.AST): |
149 |
+ result.append(child) |
150 |
+ return result |
151 |
+ |
152 |
+diff --git a/rope/base/utils/pycompat.py b/rope/base/utils/pycompat.py |
153 |
+index 1214658f..de7cf2e4 100644 |
154 |
+--- a/rope/base/utils/pycompat.py |
155 |
++++ b/rope/base/utils/pycompat.py |
156 |
+@@ -1,5 +1,5 @@ |
157 |
+ import sys |
158 |
+-import _ast |
159 |
++import ast |
160 |
+ # from rope.base import ast |
161 |
+ |
162 |
+ PY2 = sys.version_info[0] == 2 |
163 |
+@@ -15,7 +15,7 @@ |
164 |
+ str = str |
165 |
+ string_types = (str,) |
166 |
+ import builtins |
167 |
+- ast_arg_type = _ast.arg |
168 |
++ ast_arg_type = ast.arg |
169 |
+ |
170 |
+ def execfile(fn, global_vars=None, local_vars=None): |
171 |
+ with open(fn) as f: |
172 |
+@@ -34,7 +34,7 @@ def get_ast_with_items(node): |
173 |
+ |
174 |
+ string_types = (basestring,) |
175 |
+ builtins = __import__('__builtin__') |
176 |
+- ast_arg_type = _ast.Name |
177 |
++ ast_arg_type = ast.Name |
178 |
+ execfile = execfile |
179 |
+ |
180 |
+ def get_ast_arg_arg(node): |
181 |
+ |
182 |
+From 431d35d3e7ed2286bea2d13908cd80a0e42a9b13 Mon Sep 17 00:00:00 2001 |
183 |
+From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@××××.eu> |
184 |
+Date: Tue, 14 Jan 2020 15:00:36 +0100 |
185 |
+Subject: [PATCH 4/4] Work with deprecated types and using aliased ones. |
186 |
+ |
187 |
+Fixes #247 |
188 |
+--- |
189 |
+ rope/base/oi/type_hinting/utils.py | 50 ++++++++++++++++++++---------- |
190 |
+ 1 file changed, 34 insertions(+), 16 deletions(-) |
191 |
+ |
192 |
+diff --git a/rope/base/oi/type_hinting/utils.py b/rope/base/oi/type_hinting/utils.py |
193 |
+index aec82ac0..ce90dfeb 100644 |
194 |
+--- a/rope/base/oi/type_hinting/utils.py |
195 |
++++ b/rope/base/oi/type_hinting/utils.py |
196 |
+@@ -1,8 +1,12 @@ |
197 |
+-import rope.base.builtins |
198 |
++import logging |
199 |
++try: |
200 |
++ from typing import Union, Optional |
201 |
++except ImportError: |
202 |
++ pass |
203 |
+ import rope.base.utils as base_utils |
204 |
+ from rope.base.evaluate import ScopeNameFinder |
205 |
+ from rope.base.exceptions import AttributeNotFoundError |
206 |
+-from rope.base.pyobjects import PyClass, PyFunction |
207 |
++from rope.base.pyobjects import PyClass, PyDefinedObject, PyFunction, PyObject |
208 |
+ from rope.base.utils import pycompat |
209 |
+ |
210 |
+ |
211 |
+@@ -66,33 +70,47 @@ def get_lineno_for_node(assign_node): |
212 |
+ |
213 |
+ def get_mro(pyclass): |
214 |
+ # FIXME: to use real mro() result |
215 |
+- l = [pyclass] |
216 |
+- for cls in l: |
217 |
++ class_list = [pyclass] |
218 |
++ for cls in class_list: |
219 |
+ for super_cls in cls.get_superclasses(): |
220 |
+- if isinstance(super_cls, PyClass) and super_cls not in l: |
221 |
+- l.append(super_cls) |
222 |
+- return l |
223 |
++ if isinstance(super_cls, PyClass) and super_cls not in class_list: |
224 |
++ class_list.append(super_cls) |
225 |
++ return class_list |
226 |
+ |
227 |
+ |
228 |
+ def resolve_type(type_name, pyobject): |
229 |
++ # type: (str, Union[PyDefinedObject, PyObject]) -> Optional[PyDefinedObject, PyObject] |
230 |
+ """ |
231 |
+- :type type_name: str |
232 |
+- :type pyobject: rope.base.pyobjects.PyDefinedObject | rope.base.pyobjects.PyObject |
233 |
+- :rtype: rope.base.pyobjects.PyDefinedObject | rope.base.pyobjects.PyObject or None |
234 |
++ Find proper type object from its name. |
235 |
+ """ |
236 |
++ deprecated_aliases = {'collections': 'collections.abc'} |
237 |
++ ret_type = None |
238 |
++ logging.debug('Looking for %s', type_name) |
239 |
+ if '.' not in type_name: |
240 |
+ try: |
241 |
+- return pyobject.get_module().get_scope().get_name(type_name).get_object() |
242 |
+- except Exception: |
243 |
+- pass |
244 |
++ ret_type = pyobject.get_module().get_scope().get_name( |
245 |
++ type_name).get_object() |
246 |
++ except AttributeNotFoundError: |
247 |
++ logging.exception('Cannot resolve type %s', type_name) |
248 |
+ else: |
249 |
+ mod_name, attr_name = type_name.rsplit('.', 1) |
250 |
+ try: |
251 |
+ mod_finder = ScopeNameFinder(pyobject.get_module()) |
252 |
+ mod = mod_finder._find_module(mod_name).get_object() |
253 |
+- return mod.get_attribute(attr_name).get_object() |
254 |
+- except Exception: |
255 |
+- pass |
256 |
++ ret_type = mod.get_attribute(attr_name).get_object() |
257 |
++ except AttributeNotFoundError: |
258 |
++ if mod_name in deprecated_aliases: |
259 |
++ try: |
260 |
++ logging.debug('Looking for %s in %s', |
261 |
++ attr_name, deprecated_aliases[mod_name]) |
262 |
++ mod = mod_finder._find_module( |
263 |
++ deprecated_aliases[mod_name]).get_object() |
264 |
++ ret_type = mod.get_attribute(attr_name).get_object() |
265 |
++ except AttributeNotFoundError: |
266 |
++ logging.exception('Cannot resolve type %s in %s', |
267 |
++ attr_name, dir(mod)) |
268 |
++ logging.debug('ret_type = %s', ret_type) |
269 |
++ return ret_type |
270 |
+ |
271 |
+ |
272 |
+ class ParametrizeType(object): |
273 |
|
274 |
diff --git a/dev-python/rope/rope-0.16.0.ebuild b/dev-python/rope/rope-0.16.0.ebuild |
275 |
index a60999bb3c8..7854b2c3f39 100644 |
276 |
--- a/dev-python/rope/rope-0.16.0.ebuild |
277 |
+++ b/dev-python/rope/rope-0.16.0.ebuild |
278 |
@@ -21,9 +21,11 @@ IUSE="doc" |
279 |
# setup.py, using standard docutils builds docs successfully. |
280 |
DEPEND="doc? ( dev-python/docutils[${PYTHON_USEDEP}] )" |
281 |
|
282 |
-python_test() { |
283 |
- PYTHONPATH="${BUILD_DIR}/lib:." ${EPYTHON} ropetest/__init__.py |
284 |
-} |
285 |
+PATCHES=( |
286 |
+ "${FILESDIR}"/${P}-python3.7.patch |
287 |
+) |
288 |
+ |
289 |
+distutils_enable_tests pytest |
290 |
|
291 |
python_compile_all() { |
292 |
if use doc; then |
293 |
@@ -33,7 +35,7 @@ python_compile_all() { |
294 |
for i in ./*.rst; do |
295 |
rst2html.py $i > ./build/${i/rst/html} || die |
296 |
done |
297 |
- popd > /dev/null || die |
298 |
+ popd > /dev/null || die |
299 |
fi |
300 |
} |