15
0
forked from pool/python-rope

- Update to 0.19.0:

- fixes #337
  - Fix AttributeError lineno
  - Python 3.9 ast changes
  - create_generate with goal_resource param
  - Fix relative import offset calculation
  - Fix missinge lineno attribute for AssignedName ast node
  - Added _NamedExpr into `patchedast.py`
  - Add support for the walrus operator.
  - fix test case name for `test_ann_assign_node_without_target`
  - Returned _AnnAssign and checked for support assignment without value
  - fixed version restriction in tests for NamedExpr
  - Removed AnnAssign, added NeamedExpr, testa are made
  - Added _AnnAsign into `patchedast.py`
  - Extract augmented assignment
  - Fix handling of dict rename in Python 2.x
  - Improve handling of generalized dict unpacking during dict rename
  - Add expected failure test for comprehension variable scopes
  - Implement basic scoping and rename for set and dict comprehension
  - Visit subexpressions of comprehensions to collect names for scopes
  - Implement rename of inline assignment expression
  - Implement basic scoping and renaming of list and generator
    comprehension loop variables
  - Implement f-string extract refactoring
  - Refactor consume_joined_string and also fix missing
    ast.JoinedStr/FormattedValue in older python
  - Fix some f-string corner cases
  - Implement PEP-448 generalized dict-unpacking

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-rope?expand=0&rev=45
This commit is contained in:
2021-04-18 20:57:00 +00:00
committed by Git OBS Bridge
parent 6ef6c42cd1
commit 5f89dceca3
5 changed files with 36 additions and 161 deletions

View File

@@ -1,3 +1,35 @@
-------------------------------------------------------------------
Sun Apr 18 20:56:15 UTC 2021 - Matej Cepl <mcepl@suse.com>
- Update to 0.19.0:
- fixes #337
- Fix AttributeError lineno
- Python 3.9 ast changes
- create_generate with goal_resource param
- Fix relative import offset calculation
- Fix missinge lineno attribute for AssignedName ast node
- Added _NamedExpr into `patchedast.py`
- Add support for the walrus operator.
- fix test case name for `test_ann_assign_node_without_target`
- Returned _AnnAssign and checked for support assignment without value
- fixed version restriction in tests for NamedExpr
- Removed AnnAssign, added NeamedExpr, testa are made
- Added _AnnAsign into `patchedast.py`
- Extract augmented assignment
- Fix handling of dict rename in Python 2.x
- Improve handling of generalized dict unpacking during dict rename
- Add expected failure test for comprehension variable scopes
- Implement basic scoping and rename for set and dict comprehension
- Visit subexpressions of comprehensions to collect names for scopes
- Implement rename of inline assignment expression
- Implement basic scoping and renaming of list and generator
comprehension loop variables
- Implement f-string extract refactoring
- Refactor consume_joined_string and also fix missing
ast.JoinedStr/FormattedValue in older python
- Fix some f-string corner cases
- Implement PEP-448 generalized dict-unpacking
-------------------------------------------------------------------
Wed Mar 31 12:05:06 UTC 2021 - Ben Greiner <code@bnavigator.de>

View File

@@ -19,15 +19,13 @@
%define upname rope
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-rope
Version: 0.18.0
Version: 0.19.0
Release: 0
Summary: A python refactoring library
License: LGPL-3.0-or-later
Group: Development/Languages/Python
URL: https://github.com/python-rope/rope
Source: https://files.pythonhosted.org/packages/source/r/rope/rope-%{version}.tar.gz
# PATCH-FIX-UPSTREAM rope-pr333-py39.patch gh#python-rope/rope#333
Patch1: rope-pr333-py39.patch
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:786b5c38c530d4846aa68a42604f61b4e69a493390e3ca11b88df0fbfdc3ed04
size 249828

3
rope-0.19.0.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:64e6d747532e1f5c8009ec5aae3e5523a5bcedf516f39a750d57d8ed749d90da
size 252902

View File

@@ -1,155 +0,0 @@
From 5fbce2b97ba49c0900d882043acf3ff46e936d38 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@cepl.eu>
Date: Mon, 15 Mar 2021 22:06:35 +0100
Subject: [PATCH 1/4] Test for Python 3.9 as well
---
.github/workflows/main.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From a63ae26035c5493dc8b7c3bf6a70fc05dba2be98 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Sun, 14 Mar 2021 10:17:47 -0400
Subject: [PATCH 2/4] 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 <ExtSlice> cannot be found
FAILED ropetest/refactor/patchedasttest.py::PatchedASTTest::test_simple_subscript - AssertionError: False is not true : Expected <Index> but was <Constant>
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 @@ def test_ext_slice_node(self):
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 @@ def test_simple_subscript(self):
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'
From 02284e4151c2b1d549a64175ef0e3212b7737c56 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Sun, 14 Mar 2021 10:54:48 -0400
Subject: [PATCH 3/4] 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 @@ def _Subscript(self, node):
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')
From 46a3403a06aaadf9d17f87b38300c4e3febe47c5 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Fri, 19 Mar 2021 18:41:53 -0400
Subject: [PATCH 4/4] 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 @@ def _evaluate_assign_value(self, node, nodes, type_hint=False):
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 @@ def __init__(self):
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))