Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-pylsp-rope for 
openSUSE:Factory checked in at 2022-08-02 22:09:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pylsp-rope (Old)
 and      /work/SRC/openSUSE:Factory/.python-pylsp-rope.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pylsp-rope"

Tue Aug  2 22:09:34 2022 rev:6 rq:990106 version:0.1.9

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pylsp-rope/python-pylsp-rope.changes      
2021-12-25 22:41:41.154638556 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-pylsp-rope.new.1533/python-pylsp-rope.changes
    2022-08-02 22:10:26.505988668 +0200
@@ -1,0 +2,6 @@
+Sat Jul 16 10:45:05 UTC 2022 - Matej Cepl <[email protected]>
+
+- Update to 0.1.9:
+  - Implement introduce parameter refactoring
+
+-------------------------------------------------------------------

Old:
----
  pylsp-rope-0.1.8.tar.gz

New:
----
  pylsp-rope-0.1.9.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pylsp-rope.spec ++++++
--- /var/tmp/diff_new_pack.3ryUmn/_old  2022-08-02 22:10:26.953989959 +0200
+++ /var/tmp/diff_new_pack.3ryUmn/_new  2022-08-02 22:10:26.961989983 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-pylsp-rope
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %define skip_python2 1
 Name:           python-pylsp-rope
-Version:        0.1.8
+Version:        0.1.9
 Release:        0
 Summary:        Extended refactoring capabilities for Python LSP Server using 
Rope
 License:        MIT

++++++ pylsp-rope-0.1.8.tar.gz -> pylsp-rope-0.1.9.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.8/PKG-INFO 
new/pylsp-rope-0.1.9/PKG-INFO
--- old/pylsp-rope-0.1.8/PKG-INFO       2021-12-17 10:11:14.431807500 +0100
+++ new/pylsp-rope-0.1.9/PKG-INFO       2022-04-12 13:07:15.000983500 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pylsp-rope
-Version: 0.1.8
+Version: 0.1.9
 Summary: Extended refactoring capabilities for Python LSP Server using Rope.
 Home-page: https://github.com/python-rope/pylsp-rope
 Author: Lie Ryan
@@ -67,6 +67,7 @@
 - method to method object (codeAction)
 - convert local variable to field (codeAction)
 - organize imports (codeAction)
+- introduce parameter (codeAction)
 - more to come...
 
 Refer to [Rope 
documentation](https://github.com/python-rope/rope/blob/master/docs/overview.rst)
@@ -120,6 +121,11 @@
 
 This refactoring works by triggering CodeAction anywhere.
 
+### Introduce parameter
+
+This refactoring works by triggering CodeAction when the cursor is selecting
+a Python identifier, including attribute access.
+
 ## Caveat
 
 Support for working on unsaved document is currently experimental.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.8/README.md 
new/pylsp-rope-0.1.9/README.md
--- old/pylsp-rope-0.1.8/README.md      2021-12-13 20:50:04.000000000 +0100
+++ new/pylsp-rope-0.1.9/README.md      2022-03-31 17:15:48.000000000 +0200
@@ -44,6 +44,7 @@
 - method to method object (codeAction)
 - convert local variable to field (codeAction)
 - organize imports (codeAction)
+- introduce parameter (codeAction)
 - more to come...
 
 Refer to [Rope 
documentation](https://github.com/python-rope/rope/blob/master/docs/overview.rst)
@@ -97,6 +98,11 @@
 
 This refactoring works by triggering CodeAction anywhere.
 
+### Introduce parameter
+
+This refactoring works by triggering CodeAction when the cursor is selecting
+a Python identifier, including attribute access.
+
 ## Caveat
 
 Support for working on unsaved document is currently experimental.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.8/pylsp_rope/commands.py 
new/pylsp-rope-0.1.9/pylsp_rope/commands.py
--- old/pylsp-rope-0.1.8/pylsp_rope/commands.py 2021-11-04 19:38:56.000000000 
+0100
+++ new/pylsp-rope-0.1.9/pylsp_rope/commands.py 2022-03-31 16:04:51.000000000 
+0200
@@ -5,3 +5,4 @@
 COMMAND_REFACTOR_METHOD_TO_METHOD_OBJECT = 
"pylsp_rope.refactor.method_to_method_object"
 COMMAND_REFACTOR_LOCAL_TO_FIELD = "pylsp_rope.refactor.local_to_field"
 COMMAND_SOURCE_ORGANIZE_IMPORT = "pylsp_rope.source.organize_import"
+COMMAND_INTRODUCE_PARAMETER = "pylsp_rope.refactor.introduce_parameter"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.8/pylsp_rope/plugin.py 
new/pylsp-rope-0.1.9/pylsp_rope/plugin.py
--- old/pylsp-rope-0.1.8/pylsp_rope/plugin.py   2021-12-14 08:04:04.000000000 
+0100
+++ new/pylsp-rope-0.1.9/pylsp_rope/plugin.py   2022-03-31 16:40:32.000000000 
+0200
@@ -11,6 +11,7 @@
     usefunction,
     localtofield,
     importutils,
+    introduce_parameter,
 )
 
 from pylsp_rope import typing, commands
@@ -126,6 +127,11 @@
                 workspace,
                 document_uri=document.uri,
             ),
+            "Introduce parameter": CommandIntroduceParameter(
+                workspace,
+                document_uri=document.uri,
+                position=info.position,
+            ),
         }
     )
 
@@ -456,3 +462,31 @@
             resource=resource,
         )
         return rope_changeset
+
+
+class CommandIntroduceParameter(Command):
+    name = commands.COMMAND_INTRODUCE_PARAMETER
+    kind: CodeActionKind = "refactor"
+
+    document_uri: DocumentUri
+    position: typing.Range
+
+    def validate(self, info):
+        introduce_parameter.IntroduceParameter(
+            project=self.project,
+            resource=info.resource,
+            offset=info.current_document.offset_at_position(self.position),
+        )
+
+    def get_changes(self):
+        current_document, resource = get_resource(self.workspace, 
self.document_uri)
+
+        refactoring = introduce_parameter.IntroduceParameter(
+            project=self.project,
+            resource=resource,
+            offset=current_document.offset_at_position(self.position),
+        )
+        rope_changeset = refactoring.get_changes(
+            new_parameter="new_parameter",
+        )
+        return rope_changeset
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.8/pylsp_rope.egg-info/PKG-INFO 
new/pylsp-rope-0.1.9/pylsp_rope.egg-info/PKG-INFO
--- old/pylsp-rope-0.1.8/pylsp_rope.egg-info/PKG-INFO   2021-12-17 
10:11:14.000000000 +0100
+++ new/pylsp-rope-0.1.9/pylsp_rope.egg-info/PKG-INFO   2022-04-12 
13:07:14.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pylsp-rope
-Version: 0.1.8
+Version: 0.1.9
 Summary: Extended refactoring capabilities for Python LSP Server using Rope.
 Home-page: https://github.com/python-rope/pylsp-rope
 Author: Lie Ryan
@@ -67,6 +67,7 @@
 - method to method object (codeAction)
 - convert local variable to field (codeAction)
 - organize imports (codeAction)
+- introduce parameter (codeAction)
 - more to come...
 
 Refer to [Rope 
documentation](https://github.com/python-rope/rope/blob/master/docs/overview.rst)
@@ -120,6 +121,11 @@
 
 This refactoring works by triggering CodeAction anywhere.
 
+### Introduce parameter
+
+This refactoring works by triggering CodeAction when the cursor is selecting
+a Python identifier, including attribute access.
+
 ## Caveat
 
 Support for working on unsaved document is currently experimental.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.8/pylsp_rope.egg-info/SOURCES.txt 
new/pylsp-rope-0.1.9/pylsp_rope.egg-info/SOURCES.txt
--- old/pylsp-rope-0.1.8/pylsp_rope.egg-info/SOURCES.txt        2021-12-17 
10:11:14.000000000 +0100
+++ new/pylsp-rope-0.1.9/pylsp_rope.egg-info/SOURCES.txt        2022-04-12 
13:07:14.000000000 +0200
@@ -26,12 +26,14 @@
 test/test_extract.py
 test/test_import_utils.py
 test/test_inline.py
+test/test_introduce_parameter.py
 test/test_local_to_field.py
 test/test_lsp_diff.py
 test/test_method_to_method_object.py
 test/test_project.py
 test/test_usefunction.py
 test/fixtures/function.py
+test/fixtures/introduce_parameter.py
 test/fixtures/many_changes.py
 test/fixtures/many_changes_inlined.py
 test/fixtures/method.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pylsp-rope-0.1.8/pylsp_rope.egg-info/entry_points.txt 
new/pylsp-rope-0.1.9/pylsp_rope.egg-info/entry_points.txt
--- old/pylsp-rope-0.1.8/pylsp_rope.egg-info/entry_points.txt   2021-12-17 
10:11:14.000000000 +0100
+++ new/pylsp-rope-0.1.9/pylsp_rope.egg-info/entry_points.txt   2022-04-12 
13:07:14.000000000 +0200
@@ -1,3 +1,2 @@
 [pylsp]
 pylsp_rope = pylsp_rope.plugin
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.8/setup.cfg 
new/pylsp-rope-0.1.9/setup.cfg
--- old/pylsp-rope-0.1.8/setup.cfg      2021-12-17 10:11:14.435807500 +0100
+++ new/pylsp-rope-0.1.9/setup.cfg      2022-04-12 13:07:15.000983500 +0200
@@ -1,6 +1,6 @@
 [metadata]
 name = pylsp-rope
-version = 0.1.8
+version = 0.1.9
 author = Lie Ryan
 author_email = [email protected]
 url = https://github.com/python-rope/pylsp-rope
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pylsp-rope-0.1.8/test/fixtures/introduce_parameter.py 
new/pylsp-rope-0.1.9/test/fixtures/introduce_parameter.py
--- old/pylsp-rope-0.1.8/test/fixtures/introduce_parameter.py   1970-01-01 
01:00:00.000000000 +0100
+++ new/pylsp-rope-0.1.9/test/fixtures/introduce_parameter.py   2022-03-31 
16:41:22.000000000 +0200
@@ -0,0 +1,12 @@
+import sys
+
+
+def main(new_parameter=sys.stdin):
+    a = int(new_parameter.read())
+    b = 20
+    print(a + b)
+    c = a + b
+
+
+a, b = 30, 40
+print(a + b)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.8/test/test_introduce_parameter.py 
new/pylsp-rope-0.1.9/test/test_introduce_parameter.py
--- old/pylsp-rope-0.1.8/test/test_introduce_parameter.py       1970-01-01 
01:00:00.000000000 +0100
+++ new/pylsp-rope-0.1.9/test/test_introduce_parameter.py       2022-03-31 
16:41:58.000000000 +0200
@@ -0,0 +1,59 @@
+
+from pylsp_rope import commands, plugin, typing
+from pylsp_rope.text import Range
+from test.conftest import create_document
+from test.helpers import (
+    assert_code_actions_do_not_offer,
+    assert_single_document_edit,
+    assert_text_edits,
+)
+
+
+def test_introduce_parameter(config, workspace, code_action_context):
+    document = create_document(workspace, "simple.py")
+    line = 4
+    pos = document.lines[line].index("stdin.read()")
+    selection = Range((line, pos), (line, pos))
+
+    response = plugin.pylsp_code_actions(
+        config=config,
+        workspace=workspace,
+        document=document,
+        range=selection,
+        context=code_action_context,
+    )
+
+    expected: typing.CodeAction = {
+        "title": "Introduce parameter",
+        "kind": "refactor",
+        "command": {
+            "title": "Introduce parameter",
+            "command": commands.COMMAND_INTRODUCE_PARAMETER,
+            "arguments": [
+                {
+                    "document_uri": document.uri,
+                    "position": selection["start"],
+                }
+            ],
+        },
+    }
+
+    assert expected in response
+
+    assert expected["command"] is not None
+    command = expected["command"]["command"]
+    arguments = expected["command"]["arguments"]
+
+    response = plugin.pylsp_execute_command(
+        config=config,
+        workspace=workspace,
+        command=command,
+        arguments=arguments,
+    )
+
+    edit_request = workspace._endpoint.request.call_args
+
+    document_edits = assert_single_document_edit(edit_request, document)
+    new_text = assert_text_edits(document_edits, 
target="introduce_parameter.py")
+    assert "new_parameter=sys.stdin" in new_text
+    assert "new_parameter.read()" in new_text

Reply via email to