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 2024-03-20 21:18:38
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pylsp-rope (Old)
 and      /work/SRC/openSUSE:Factory/.python-pylsp-rope.new.1905 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pylsp-rope"

Wed Mar 20 21:18:38 2024 rev:10 rq:1159847 version:0.1.16

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pylsp-rope/python-pylsp-rope.changes      
2024-03-13 22:18:29.376075409 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-pylsp-rope.new.1905/python-pylsp-rope.changes
    2024-03-20 21:21:52.854656311 +0100
@@ -1,0 +2,6 @@
+Wed Mar 20 12:21:50 UTC 2024 - Matej Cepl <mc...@cepl.eu>
+
+- Update to 0.1.16:
+  - Implement lsp_rename()
+
+-------------------------------------------------------------------

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

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

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

Other differences:
------------------
++++++ python-pylsp-rope.spec ++++++
--- /var/tmp/diff_new_pack.K8x72B/_old  2024-03-20 21:21:53.290672328 +0100
+++ /var/tmp/diff_new_pack.K8x72B/_new  2024-03-20 21:21:53.290672328 +0100
@@ -17,22 +17,21 @@
 
 
 Name:           python-pylsp-rope
-Version:        0.1.15
+Version:        0.1.16
 Release:        0
 Summary:        Extended refactoring capabilities for Python LSP Server using 
Rope
 License:        MIT
 URL:            https://github.com/python-rope/pylsp-rope
-# Cannot use released tarball until gh#python-rope/pylsp-rope#25 is fixed
 Source:         
https://files.pythonhosted.org/packages/source/p/pylsp-rope/pylsp-rope-%{version}.tar.gz
-# Source:         pylsp-rope-%%{version}.tar.gz
 BuildRequires:  %{python_module pip}
 BuildRequires:  %{python_module setuptools}
+BuildRequires:  %{python_module typing_extensions if %python-base <= 3.9}
 BuildRequires:  %{python_module wheel}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
-BuildRequires:  (python3-typing_extensions if python3-base <= 3.6)
 Requires:       python-python-lsp-server
 Requires:       python-rope
+Requires:       (python-typing_extensions if python-base <= 3.9)
 Suggests:       python-twine
 BuildArch:      noarch
 # SECTION test requirements

++++++ pylsp-rope-0.1.15.tar.gz -> pylsp-rope-0.1.16.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/PKG-INFO 
new/pylsp-rope-0.1.16/PKG-INFO
--- old/pylsp-rope-0.1.15/PKG-INFO      2024-03-12 04:29:09.012215900 +0100
+++ new/pylsp-rope-0.1.16/PKG-INFO      2024-03-20 11:44:30.462613600 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pylsp-rope
-Version: 0.1.15
+Version: 0.1.16
 Summary: Extended refactoring capabilities for Python LSP Server using Rope.
 Home-page: https://github.com/python-rope/pylsp-rope
 Author: Lie Ryan
@@ -25,11 +25,14 @@
 Requires-Dist: pytest; extra == "dev"
 Requires-Dist: twine; extra == "dev"
 Provides-Extra: test
+Requires-Dist: flake8; extra == "test"
 Requires-Dist: pytest; extra == "test"
+Requires-Dist: pytest-cov; extra == "test"
 
 # pylsp-rope
 
-[![Tests](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml/badge.svg)](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml)
+[![Tests](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml/badge.svg)](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml)
 
+[![codecov](https://codecov.io/gh/python-rope/pylsp-rope/graph/badge.svg?token=LMO7PW0AEK)](https://codecov.io/gh/python-rope/pylsp-rope)
 
 Extended refactoring capabilities for Python LSP Server using
 [Rope](https://github.com/python-rope/rope).
@@ -60,28 +63,45 @@
 
 ## Configuration
 
-There is no configuration yet.
+You can enable rename support using pylsp-rope with workspace config key
+`pylsp.plugins.pylsp_rope.rename`. 
+
+Note that this differs from the config key `pylsp.plugins.rope_rename.enabled`
+that is used for the rope rename implementation using the python-lsp-rope's
+builtin `rope_rename` plugin. To avoid confusion, avoid enabling more than one
+python-lsp-server rename plugin.
 
 ## Features
 
 This plugin adds the following features to python-lsp-server:
 
-- extract method (codeAction)
-- extract variable (codeAction)
-- inline method/variable/parameter (codeAction)
-- use function (codeAction)
-- method to method object (codeAction)
-- convert local variable to field (codeAction)
-- organize imports (codeAction)
-- introduce parameter (codeAction)
-- generate variable/function/class from undefined variable (codeAction)
-- more to come...
+Rename: 
+
+- rename everything: classes, functions, modules, packages (disabled by 
default)
+
+Code Action:
+
+- extract method
+- extract variable 
+- inline method/variable/parameter 
+- use function 
+- method to method object 
+- convert local variable to field 
+- organize imports 
+- introduce parameter 
+- generate variable/function/class from undefined variable 
 
 Refer to [Rope 
documentation](https://github.com/python-rope/rope/blob/master/docs/overview.rst)
 for more details on how these refactoring works.
 
 ## Usage
 
+### Rename
+
+When Rename is triggered, rename the symbol under the cursor. If the symbol
+under the cursor points to a module/package, it will move that module/package
+files.
+
 ### Extract method
 
 Variants: 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/README.md 
new/pylsp-rope-0.1.16/README.md
--- old/pylsp-rope-0.1.15/README.md     2024-03-12 04:29:02.000000000 +0100
+++ new/pylsp-rope-0.1.16/README.md     2024-03-20 11:44:24.000000000 +0100
@@ -1,6 +1,7 @@
 # pylsp-rope
 
-[![Tests](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml/badge.svg)](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml)
+[![Tests](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml/badge.svg)](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml)
 
+[![codecov](https://codecov.io/gh/python-rope/pylsp-rope/graph/badge.svg?token=LMO7PW0AEK)](https://codecov.io/gh/python-rope/pylsp-rope)
 
 Extended refactoring capabilities for Python LSP Server using
 [Rope](https://github.com/python-rope/rope).
@@ -31,28 +32,45 @@
 
 ## Configuration
 
-There is no configuration yet.
+You can enable rename support using pylsp-rope with workspace config key
+`pylsp.plugins.pylsp_rope.rename`. 
+
+Note that this differs from the config key `pylsp.plugins.rope_rename.enabled`
+that is used for the rope rename implementation using the python-lsp-rope's
+builtin `rope_rename` plugin. To avoid confusion, avoid enabling more than one
+python-lsp-server rename plugin.
 
 ## Features
 
 This plugin adds the following features to python-lsp-server:
 
-- extract method (codeAction)
-- extract variable (codeAction)
-- inline method/variable/parameter (codeAction)
-- use function (codeAction)
-- method to method object (codeAction)
-- convert local variable to field (codeAction)
-- organize imports (codeAction)
-- introduce parameter (codeAction)
-- generate variable/function/class from undefined variable (codeAction)
-- more to come...
+Rename: 
+
+- rename everything: classes, functions, modules, packages (disabled by 
default)
+
+Code Action:
+
+- extract method
+- extract variable 
+- inline method/variable/parameter 
+- use function 
+- method to method object 
+- convert local variable to field 
+- organize imports 
+- introduce parameter 
+- generate variable/function/class from undefined variable 
 
 Refer to [Rope 
documentation](https://github.com/python-rope/rope/blob/master/docs/overview.rst)
 for more details on how these refactoring works.
 
 ## Usage
 
+### Rename
+
+When Rename is triggered, rename the symbol under the cursor. If the symbol
+under the cursor points to a module/package, it will move that module/package
+files.
+
 ### Extract method
 
 Variants: 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/pylsp_rope/plugin.py 
new/pylsp-rope-0.1.16/pylsp_rope/plugin.py
--- old/pylsp-rope-0.1.15/pylsp_rope/plugin.py  2024-03-12 04:29:02.000000000 
+0100
+++ new/pylsp-rope-0.1.16/pylsp_rope/plugin.py  2024-03-20 11:44:24.000000000 
+0100
@@ -1,11 +1,19 @@
 import logging
-from typing import List
+from typing import List, Optional
 
-from pylsp import hookimpl
+from pylsp import hookimpl, uris
+from rope.base import libutils
 from pylsp.lsp import MessageType
+from rope.refactor.rename import Rename
 
 from pylsp_rope import refactoring, typing, commands
-from pylsp_rope.project import get_project, get_resource, get_resources
+from pylsp_rope.project import (
+    get_project,
+    get_resource,
+    get_resources,
+    rope_changeset_to_workspace_edit,
+    new_project,
+)
 
 
 logger = logging.getLogger(__name__)
@@ -15,7 +23,6 @@
 def pylsp_settings():
     logger.info("Initializing pylsp_rope")
 
-    # Disable default plugins that conflicts with our plugin
     return {
         "plugins": {
             # "autopep8_format": {"enabled": False},
@@ -35,6 +42,10 @@
             # "references": {"enabled": False},
             # "rope_completion": {"enabled": False},
             # "rope_rename": {"enabled": False},
+            "pylsp_rope": {
+                "enabled": True,
+                "rename": False,
+            },
             # "signature": {"enabled": False},
             # "symbols": {"enabled": False},
             # "yapf_format": {"enabled": False},
@@ -49,7 +60,11 @@
 
 @hookimpl
 def pylsp_code_actions(
-    config, workspace, document, range, context
+    config,
+    workspace,
+    document,
+    range,
+    context,
 ) -> List[typing.CodeAction]:
     logger.info("textDocument/codeAction: %s %s %s", document, range, context)
 
@@ -155,3 +170,41 @@
             f"pylsp-rope: {exc}",
             msg_type=MessageType.Error,
         )
+
+
+@hookimpl
+def pylsp_rename(
+    config,
+    workspace,
+    document,
+    position,
+    new_name,
+) -> Optional[typing.WorkspaceEdit]:
+    cfg = config.plugin_settings("pylsp_rope", document_path=document.uri)
+    if not cfg.get("rename", False):
+        return None
+
+    logger.info("textDocument/rename: %s %s %s", document, position, new_name)
+    project = new_project(workspace)  # FIXME: we shouldn't have to always 
keep creating new projects here
+    document, resource = get_resource(workspace, document.uri, project=project)
+
+    rename = Rename(
+        project=project,
+        resource=resource,
+        offset=document.offset_at_position(position),
+    )
+
+    logger.debug(
+        "Executing rename of %s to %s",
+        document.word_at_position(position),
+        new_name,
+    )
+
+    rope_changeset = rename.get_changes(new_name, in_hierarchy=True, docs=True)
+
+    logger.debug("Finished rename: %s", rope_changeset.changes)
+    workspace_edit = rope_changeset_to_workspace_edit(
+        workspace,
+        rope_changeset,
+    )
+    return workspace_edit
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/pylsp_rope/project.py 
new/pylsp-rope-0.1.16/pylsp_rope/project.py
--- old/pylsp-rope-0.1.15/pylsp_rope/project.py 2024-03-12 04:29:02.000000000 
+0100
+++ new/pylsp-rope-0.1.16/pylsp_rope/project.py 2024-03-20 11:44:24.000000000 
+0100
@@ -1,3 +1,4 @@
+from __future__ import annotations
 import logging
 from functools import lru_cache
 from typing import List, Dict, Tuple, Optional, Literal, cast
@@ -24,15 +25,34 @@
 
 @lru_cache(maxsize=None)
 def get_project(workspace) -> rope.Project:
+    """Get a cached rope Project or create one if it doesn't exist yet"""
+    return new_project(workspace)
+
+
+def new_project(workspace) -> rope.Project:
+    """
+    Always create a new Project, some operations like rename seems to have
+    problems when using the cached Project
+    """
     fscommands = WorkspaceFileCommands(workspace)
     return rope.Project(workspace.root_path, fscommands=fscommands)
 
 
 def get_resource(
-    workspace, document_uri: DocumentUri
+    workspace,
+    document_uri: DocumentUri,
+    *,
+    project: rope.Project = None,
 ) -> Tuple[workspace.Document, rope.Resource]:
+    """
+    Return a Document and Resource related to an LSP Document.
+
+    `project` must be provided if not using instances of rope Project from
+    `pylsp_rope.project.get_project()`.
+    """
     document = workspace.get_document(document_uri)
-    resource = libutils.path_to_resource(get_project(workspace), document.path)
+    project = project or get_project(workspace)
+    resource = libutils.path_to_resource(project, document.path)
     return document, resource
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/pylsp_rope.egg-info/PKG-INFO 
new/pylsp-rope-0.1.16/pylsp_rope.egg-info/PKG-INFO
--- old/pylsp-rope-0.1.15/pylsp_rope.egg-info/PKG-INFO  2024-03-12 
04:29:08.000000000 +0100
+++ new/pylsp-rope-0.1.16/pylsp_rope.egg-info/PKG-INFO  2024-03-20 
11:44:30.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pylsp-rope
-Version: 0.1.15
+Version: 0.1.16
 Summary: Extended refactoring capabilities for Python LSP Server using Rope.
 Home-page: https://github.com/python-rope/pylsp-rope
 Author: Lie Ryan
@@ -25,11 +25,14 @@
 Requires-Dist: pytest; extra == "dev"
 Requires-Dist: twine; extra == "dev"
 Provides-Extra: test
+Requires-Dist: flake8; extra == "test"
 Requires-Dist: pytest; extra == "test"
+Requires-Dist: pytest-cov; extra == "test"
 
 # pylsp-rope
 
-[![Tests](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml/badge.svg)](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml)
+[![Tests](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml/badge.svg)](https://github.com/python-rope/pylsp-rope/actions/workflows/run-test.yml)
 
+[![codecov](https://codecov.io/gh/python-rope/pylsp-rope/graph/badge.svg?token=LMO7PW0AEK)](https://codecov.io/gh/python-rope/pylsp-rope)
 
 Extended refactoring capabilities for Python LSP Server using
 [Rope](https://github.com/python-rope/rope).
@@ -60,28 +63,45 @@
 
 ## Configuration
 
-There is no configuration yet.
+You can enable rename support using pylsp-rope with workspace config key
+`pylsp.plugins.pylsp_rope.rename`. 
+
+Note that this differs from the config key `pylsp.plugins.rope_rename.enabled`
+that is used for the rope rename implementation using the python-lsp-rope's
+builtin `rope_rename` plugin. To avoid confusion, avoid enabling more than one
+python-lsp-server rename plugin.
 
 ## Features
 
 This plugin adds the following features to python-lsp-server:
 
-- extract method (codeAction)
-- extract variable (codeAction)
-- inline method/variable/parameter (codeAction)
-- use function (codeAction)
-- method to method object (codeAction)
-- convert local variable to field (codeAction)
-- organize imports (codeAction)
-- introduce parameter (codeAction)
-- generate variable/function/class from undefined variable (codeAction)
-- more to come...
+Rename: 
+
+- rename everything: classes, functions, modules, packages (disabled by 
default)
+
+Code Action:
+
+- extract method
+- extract variable 
+- inline method/variable/parameter 
+- use function 
+- method to method object 
+- convert local variable to field 
+- organize imports 
+- introduce parameter 
+- generate variable/function/class from undefined variable 
 
 Refer to [Rope 
documentation](https://github.com/python-rope/rope/blob/master/docs/overview.rst)
 for more details on how these refactoring works.
 
 ## Usage
 
+### Rename
+
+When Rename is triggered, rename the symbol under the cursor. If the symbol
+under the cursor points to a module/package, it will move that module/package
+files.
+
 ### Extract method
 
 Variants: 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/pylsp_rope.egg-info/SOURCES.txt 
new/pylsp-rope-0.1.16/pylsp_rope.egg-info/SOURCES.txt
--- old/pylsp-rope-0.1.15/pylsp_rope.egg-info/SOURCES.txt       2024-03-12 
04:29:09.000000000 +0100
+++ new/pylsp-rope-0.1.16/pylsp_rope.egg-info/SOURCES.txt       2024-03-20 
11:44:30.000000000 +0100
@@ -33,6 +33,7 @@
 test/test_lsp_diff.py
 test/test_method_to_method_object.py
 test/test_project.py
+test/test_rename.py
 test/test_usefunction.py
 test/fixtures/function.py
 test/fixtures/generate_class.py
@@ -55,5 +56,9 @@
 test/fixtures/simple_extract_method_with_similar.py
 test/fixtures/simple_extract_variable.py
 test/fixtures/simple_extract_variable_with_similar.py
+test/fixtures/simple_rename.py
+test/fixtures/simple_rename_extra.py
+test/fixtures/simple_rename_extra_result.py
+test/fixtures/simple_rename_result.py
 test/fixtures/undefined_variable.py
 test/fixtures/use_function.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/pylsp_rope.egg-info/requires.txt 
new/pylsp-rope-0.1.16/pylsp_rope.egg-info/requires.txt
--- old/pylsp-rope-0.1.15/pylsp_rope.egg-info/requires.txt      2024-03-12 
04:29:08.000000000 +0100
+++ new/pylsp-rope-0.1.16/pylsp_rope.egg-info/requires.txt      2024-03-20 
11:44:30.000000000 +0100
@@ -10,4 +10,6 @@
 twine
 
 [test]
+flake8
 pytest
+pytest-cov
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/setup.cfg 
new/pylsp-rope-0.1.16/setup.cfg
--- old/pylsp-rope-0.1.15/setup.cfg     2024-03-12 04:29:09.012215900 +0100
+++ new/pylsp-rope-0.1.16/setup.cfg     2024-03-20 11:44:30.462613600 +0100
@@ -1,6 +1,6 @@
 [metadata]
 name = pylsp-rope
-version = 0.1.15
+version = 0.1.16
 author = Lie Ryan
 author_email = lie.1...@gmail.com
 url = https://github.com/python-rope/pylsp-rope
@@ -38,7 +38,9 @@
        pytest
        twine
 test = 
+       flake8
        pytest
+       pytest-cov
 
 [pycodestyle]
 max-line-length = 88
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/test/fixtures/simple_rename.py 
new/pylsp-rope-0.1.16/test/fixtures/simple_rename.py
--- old/pylsp-rope-0.1.15/test/fixtures/simple_rename.py        1970-01-01 
01:00:00.000000000 +0100
+++ new/pylsp-rope-0.1.16/test/fixtures/simple_rename.py        2024-03-20 
11:44:24.000000000 +0100
@@ -0,0 +1,5 @@
+class Test1():
+    pass
+
+class Test2(Test1):
+    pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pylsp-rope-0.1.15/test/fixtures/simple_rename_extra.py 
new/pylsp-rope-0.1.16/test/fixtures/simple_rename_extra.py
--- old/pylsp-rope-0.1.15/test/fixtures/simple_rename_extra.py  1970-01-01 
01:00:00.000000000 +0100
+++ new/pylsp-rope-0.1.16/test/fixtures/simple_rename_extra.py  2024-03-20 
11:44:24.000000000 +0100
@@ -0,0 +1,3 @@
+from simple_rename import Test1
+
+x = Test1()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pylsp-rope-0.1.15/test/fixtures/simple_rename_extra_result.py 
new/pylsp-rope-0.1.16/test/fixtures/simple_rename_extra_result.py
--- old/pylsp-rope-0.1.15/test/fixtures/simple_rename_extra_result.py   
1970-01-01 01:00:00.000000000 +0100
+++ new/pylsp-rope-0.1.16/test/fixtures/simple_rename_extra_result.py   
2024-03-20 11:44:24.000000000 +0100
@@ -0,0 +1,3 @@
+from simple_rename import ShouldBeRenamed
+
+x = ShouldBeRenamed()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pylsp-rope-0.1.15/test/fixtures/simple_rename_result.py 
new/pylsp-rope-0.1.16/test/fixtures/simple_rename_result.py
--- old/pylsp-rope-0.1.15/test/fixtures/simple_rename_result.py 1970-01-01 
01:00:00.000000000 +0100
+++ new/pylsp-rope-0.1.16/test/fixtures/simple_rename_result.py 2024-03-20 
11:44:24.000000000 +0100
@@ -0,0 +1,5 @@
+class ShouldBeRenamed():
+    pass
+
+class Test2(ShouldBeRenamed):
+    pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pylsp-rope-0.1.15/test/test_rename.py 
new/pylsp-rope-0.1.16/test/test_rename.py
--- old/pylsp-rope-0.1.15/test/test_rename.py   1970-01-01 01:00:00.000000000 
+0100
+++ new/pylsp-rope-0.1.16/test/test_rename.py   2024-03-20 11:44:24.000000000 
+0100
@@ -0,0 +1,67 @@
+import pytest
+from pylsp_rope import typing
+from pylsp_rope.plugin import pylsp_rename
+from pylsp_rope.text import Position
+from test.conftest import create_document
+from test.helpers import assert_text_edits, assert_modified_documents
+
+
+@pytest.fixture(autouse=True)
+def enable_pylsp_rope_rename_plugin(config):
+    config._plugin_settings["plugins"]["pylsp_rope"] = {"rename": True}
+    return config
+
+
+def test_rope_rename(config, workspace) -> None:
+    document = create_document(workspace, "simple_rename.py")
+    extra_document = create_document(workspace, "simple_rename_extra.py")
+    line = 0
+    pos = document.lines[line].index("Test1")
+    position = Position(line, pos)
+
+    response: typing.SimpleWorkspaceEdit = pylsp_rename(config, workspace, 
document, position, "ShouldBeRenamed")
+    assert len(response.keys()) == 1
+
+    assert_modified_documents(response, {document.uri, extra_document.uri})
+
+    new_text = assert_text_edits(
+        response["changes"][document.uri], target="simple_rename_result.py"
+    )
+    assert "class ShouldBeRenamed()" in new_text
+    assert "class Test2(ShouldBeRenamed)" in new_text
+
+    new_text = assert_text_edits(
+        response["changes"][extra_document.uri], 
target="simple_rename_extra_result.py"
+    )
+    assert "from simple_rename import ShouldBeRenamed" in new_text
+    assert "x = ShouldBeRenamed()" in new_text
+
+
+def test_rope_rename_disabled(config, workspace) -> None:
+    document = create_document(workspace, "simple_rename.py")
+    extra_document = create_document(workspace, "simple_rename_extra.py")
+    line = 0
+    pos = document.lines[line].index("Test1")
+    position = Position(line, pos)
+
+    plugin_settings = config.plugin_settings("pylsp_rope", document.uri)
+    plugin_settings["rename"] = False
+
+    response: typing.SimpleWorkspaceEdit = pylsp_rename(config, workspace, 
document, position, "ShouldBeRenamed")
+
+    assert response is None
+
+
+def test_rope_rename_missing_key(config, workspace) -> None:
+    document = create_document(workspace, "simple_rename.py")
+    extra_document = create_document(workspace, "simple_rename_extra.py")
+    line = 0
+    pos = document.lines[line].index("Test1")
+    position = Position(line, pos)
+
+    plugin_settings = config.plugin_settings("pylsp_rope", document.uri)
+    del plugin_settings["rename"]
+
+    response: typing.SimpleWorkspaceEdit = pylsp_rename(config, workspace, 
document, position, "ShouldBeRenamed")
+
+    assert response is None

Reply via email to