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-13 22:17:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pylsp-rope (Old)
and /work/SRC/openSUSE:Factory/.python-pylsp-rope.new.1770 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pylsp-rope"
Wed Mar 13 22:17:41 2024 rev:9 rq:1157102 version:0.1.15
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pylsp-rope/python-pylsp-rope.changes
2023-01-17 17:35:35.901280129 +0100
+++
/work/SRC/openSUSE:Factory/.python-pylsp-rope.new.1770/python-pylsp-rope.changes
2024-03-13 22:18:29.376075409 +0100
@@ -1,0 +2,37 @@
+Tue Mar 12 07:46:28 UTC 2024 - Matej Cepl <[email protected]>
+
+- Update to 0.1.15 (we can do released tarballs again):
+ - Change WorkspaceEdit to use documentChanges
+ - Add files missing from the source packages needed for running
+ tests
+
+-------------------------------------------------------------------
+Mon Mar 11 18:10:25 UTC 2024 - [email protected]
+
+- Because of gh#python-rope/pylsp-rope#25 we have to switch to
+ git checkout again.
+- Update to version 0.1.13+git.1710166725.0bcf4d3:
+ * Add fallback import for TypeGuard
+ * Hardcode executeCommand to use WorkspaceEditWithChanges
+ * Blacken
+ * Implement rope_changeset_to_workspace_edit(workspace_edit_format) argument
+ * Add TypeGuard for distinguishing between WorkspaceEditWithChanges and
WorkspaceEditWithDocumentChanges
+ * Fix type hints to use List instead of list
+ * Remove SimpleWorkspaceEdit, replaced with WorkspaceEditWithChanges
+ * Implement convert_workspace_edit_document_changes_to_changes()
+ * Refine the type annotation for rope_changeset_to_workspace_edit()
+
+-------------------------------------------------------------------
+Mon Mar 11 17:51:52 UTC 2024 - Matej Cepl <[email protected]>
+
+- Update to 0.1.13:
+ - Revert "remove non-standard title in executeCommand"
+ - Remove pkg_resources, replace with importlib.resources
+ - Drop Python 3.7, add Python 3.12
+- Update to 0.1.12:
+ - remove non-standard title in executeCommand
+ - Use List, not list, this syntax isn't supported yet in our oldest
supported version
+ - fix type hint issue in CommandRefactorUseFunction
+ - Update python-lsp/cookiecutter-pylsp-plugin link
+
+-------------------------------------------------------------------
Old:
----
pylsp-rope-0.1.11.tar.gz
New:
----
pylsp-rope-0.1.15.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pylsp-rope.spec ++++++
--- /var/tmp/diff_new_pack.2RreVT/_old 2024-03-13 22:18:30.976134272 +0100
+++ /var/tmp/diff_new_pack.2RreVT/_new 2024-03-13 22:18:30.976134272 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-pylsp-rope
#
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,30 +16,31 @@
#
-%define skip_python2 1
Name: python-pylsp-rope
-Version: 0.1.11
+Version: 0.1.15
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 wheel}
+BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: (python3-typing_extensions if python3-base <= 3.6)
-# SECTION test requirements
-BuildRequires: %{python_module python-lsp-server}
-BuildRequires: %{python_module pytest}
-BuildRequires: %{python_module rope}
-# /SECTION
-BuildRequires: fdupes
Requires: python-python-lsp-server
Requires: python-rope
Suggests: python-twine
BuildArch: noarch
+# SECTION test requirements
+BuildRequires: %{python_module pytest}
+BuildRequires: %{python_module python-lsp-server}
+BuildRequires: %{python_module rope}
+BuildRequires: %{python_module typing_extensions}
+# /SECTION
%python_subpackages
%description
++++++ _service ++++++
--- /var/tmp/diff_new_pack.2RreVT/_old 2024-03-13 22:18:31.004135302 +0100
+++ /var/tmp/diff_new_pack.2RreVT/_new 2024-03-13 22:18:31.008135449 +0100
@@ -1,16 +1,16 @@
<services>
- <service name="tar_scm" mode="disabled">
+ <service name="tar_scm" mode="manual">
<param name="url">https://github.com/python-rope/pylsp-rope.git</param>
<param name="scm">git</param>
- <param name="versionprefix">0.1.2+git</param>
+ <param name="versionprefix">0.1.13+git</param>
<param name="revision">main</param>
<param name="changesgenerate">enable</param>
<param name="changesauthor">[email protected]</param>
</service>
- <service mode="disabled" name="recompress">
+ <service mode="manual" name="recompress">
<param name="file">*.tar</param>
<param name="compression">gz</param>
</service>
- <service mode="disabled" name="set_version" />
+ <service mode="manual" name="set_version" />
</services>
++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.2RreVT/_old 2024-03-13 22:18:31.028136185 +0100
+++ /var/tmp/diff_new_pack.2RreVT/_new 2024-03-13 22:18:31.032136332 +0100
@@ -1,6 +1,6 @@
<servicedata>
<service name="tar_scm">
<param
name="url">https://github.com/python-rope/pylsp-rope.git</param>
- <param
name="changesrevision">9245130880d467f1a3bcacf52ba7fdf8ad2287b2</param></service></servicedata>
+ <param
name="changesrevision">0bcf4d3b412b7fe5c9933f62807e35625708936c</param></service></servicedata>
(No newline at EOF)
++++++ pylsp-rope-0.1.11.tar.gz -> pylsp-rope-0.1.15.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/MANIFEST.in
new/pylsp-rope-0.1.15/MANIFEST.in
--- old/pylsp-rope-0.1.11/MANIFEST.in 2022-08-25 05:26:01.000000000 +0200
+++ new/pylsp-rope-0.1.15/MANIFEST.in 2024-03-12 04:29:02.000000000 +0100
@@ -1 +1 @@
-recursive-include test/fixtures *.py
+recursive-include test *.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/PKG-INFO
new/pylsp-rope-0.1.15/PKG-INFO
--- old/pylsp-rope-0.1.11/PKG-INFO 2023-01-17 08:06:05.202077000 +0100
+++ new/pylsp-rope-0.1.15/PKG-INFO 2024-03-12 04:29:09.012215900 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pylsp-rope
-Version: 0.1.11
+Version: 0.1.15
Summary: Extended refactoring capabilities for Python LSP Server using Rope.
Home-page: https://github.com/python-rope/pylsp-rope
Author: Lie Ryan
@@ -15,10 +15,17 @@
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.6
Description-Content-Type: text/markdown
-Provides-Extra: dev
-Provides-Extra: test
License-File: LICENSE
License-File: AUTHORS.txt
+Requires-Dist: python-lsp-server
+Requires-Dist: rope>=0.21.0
+Requires-Dist: typing-extensions; python_version < "3.10"
+Provides-Extra: dev
+Requires-Dist: build; extra == "dev"
+Requires-Dist: pytest; extra == "dev"
+Requires-Dist: twine; extra == "dev"
+Provides-Extra: test
+Requires-Dist: pytest; extra == "test"
# pylsp-rope
@@ -158,9 +165,15 @@
See
[CONTRIBUTING.md](https://github.com/python-rope/pylsp-rope/blob/main/CONTRIBUTING.md).
+## Packaging status
+
+[](https://repology.org/project/python:pylsp-rope/versions)
+
+[](https://repology.org/project/python:lsp-rope/versions)
+
## Credits
This package was created with
[Cookiecutter](https://github.com/audreyr/cookiecutter) from
-[lieryan/cookiecutter-pylsp-plugin](https://github.com/lieryan/cookiecutter-pylsp-plugin)
+[python-lsp/cookiecutter-pylsp-plugin](https://github.com/python-lsp/cookiecutter-pylsp-plugin)
project template.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/README.md
new/pylsp-rope-0.1.15/README.md
--- old/pylsp-rope-0.1.11/README.md 2023-01-17 08:01:07.000000000 +0100
+++ new/pylsp-rope-0.1.15/README.md 2024-03-12 04:29:02.000000000 +0100
@@ -136,9 +136,15 @@
See
[CONTRIBUTING.md](https://github.com/python-rope/pylsp-rope/blob/main/CONTRIBUTING.md).
+## Packaging status
+
+[](https://repology.org/project/python:pylsp-rope/versions)
+
+[](https://repology.org/project/python:lsp-rope/versions)
+
## Credits
This package was created with
[Cookiecutter](https://github.com/audreyr/cookiecutter) from
-[lieryan/cookiecutter-pylsp-plugin](https://github.com/lieryan/cookiecutter-pylsp-plugin)
+[python-lsp/cookiecutter-pylsp-plugin](https://github.com/python-lsp/cookiecutter-pylsp-plugin)
project template.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/pylsp_rope/plugin.py
new/pylsp-rope-0.1.15/pylsp_rope/plugin.py
--- old/pylsp-rope-0.1.11/pylsp_rope/plugin.py 2023-01-17 08:04:28.000000000
+0100
+++ new/pylsp-rope-0.1.15/pylsp_rope/plugin.py 2024-03-12 04:29:02.000000000
+0100
@@ -140,7 +140,11 @@
commands = {cmd.name: cmd for cmd in refactoring.Command.__subclasses__()}
try:
- return commands[command](workspace, **arguments[0])()
+ return commands[command](workspace, **arguments[0])(
+ # FIXME: Hardcode executeCommand to use WorkspaceEditWithChanges
+ # We need to upgrade this at some point.
+ workspace_edit_format=["changes"],
+ )
except Exception as exc:
logger.exception(
"Exception when doing workspace/executeCommand: %s",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/pylsp_rope/project.py
new/pylsp-rope-0.1.15/pylsp_rope/project.py
--- old/pylsp-rope-0.1.11/pylsp_rope/project.py 2021-11-04 03:25:30.000000000
+0100
+++ new/pylsp-rope-0.1.15/pylsp_rope/project.py 2024-03-12 04:29:02.000000000
+0100
@@ -1,6 +1,6 @@
import logging
from functools import lru_cache
-from typing import List, Dict, Tuple
+from typing import List, Dict, Tuple, Optional, Literal, cast
from pylsp import uris, workspace
from rope.base import libutils
@@ -8,7 +8,15 @@
from pylsp_rope import rope
from pylsp_rope.lsp_diff import lsp_diff
-from pylsp_rope.typing import WorkspaceEdit, DocumentUri, TextEdit, Line
+from pylsp_rope.typing import (
+ WorkspaceEditWithChanges,
+ WorkspaceEditWithDocumentChanges,
+ WorkspaceEdit,
+ DocumentUri,
+ TextEdit,
+ Line,
+ TextDocumentEdit,
+)
logger = logging.getLogger(__name__)
@@ -38,36 +46,92 @@
return workspace.get_document(uris.from_fs_path(resource.real_path))
-def rope_changeset_to_workspace_edit(
- workspace, rope_changeset: rope.ChangeSet
-) -> WorkspaceEdit:
- def _get_contents(change: rope.Change) -> Tuple[List[Line], List[Line]]:
- old = change.old_contents
- new = change.new_contents
- if old is None:
- if change.resource.exists():
- old = change.resource.read()
- else:
- old = ""
- return old.splitlines(keepends=True), new.splitlines(keepends=True)
+def _get_contents(change: rope.Change) -> Tuple[List[Line], List[Line]]:
+ old = change.old_contents
+ new = change.new_contents
+ if old is None:
+ if change.resource.exists():
+ old = change.resource.read()
+ else:
+ old = ""
+ return old.splitlines(keepends=True), new.splitlines(keepends=True)
+
+def convert_workspace_edit_document_changes_to_changes(
+ workspace_edit: WorkspaceEditWithDocumentChanges,
+) -> WorkspaceEditWithChanges:
workspace_changeset: Dict[DocumentUri, List[TextEdit]] = {}
+ for change in workspace_edit["documentChanges"] or []:
+ document_changes = workspace_changeset.setdefault(
+ change["textDocument"]["uri"],
+ [],
+ )
+ document_changes.extend(change["edits"])
+
+ return {
+ "changes": workspace_changeset,
+ }
+
+
+def _rope_changeset_to_workspace_edit(
+ workspace, rope_changeset: rope.ChangeSet
+) -> WorkspaceEditWithDocumentChanges:
+ workspace_changeset: List[TextDocumentEdit] = []
for change in rope_changeset.changes:
lines_old, lines_new = _get_contents(change)
document = get_document(workspace, change.resource)
- document_changes = workspace_changeset.setdefault(document.uri, [])
- document_changes.extend(lsp_diff(lines_old, lines_new))
+ workspace_changeset.append(
+ {
+ "textDocument": {
+ "uri": document.uri,
+ "version": document.version,
+ },
+ "edits": list(lsp_diff(lines_old, lines_new)),
+ }
+ )
return {
- "changes": workspace_changeset,
+ "documentChanges": workspace_changeset,
}
-def apply_rope_changeset(workspace, rope_changeset: rope.ChangeSet) -> None:
+WorkspaceEditFormat = Literal["changes", "documentChanges"]
+DEFAULT_WORKSPACE_EDIT_FORMAT: List[WorkspaceEditFormat] = ["changes"]
+
+
+def rope_changeset_to_workspace_edit(
+ workspace,
+ rope_changeset: rope.ChangeSet,
+ workspace_edit_format: List[WorkspaceEditFormat] =
DEFAULT_WORKSPACE_EDIT_FORMAT,
+) -> WorkspaceEdit:
+ assert len(workspace_edit_format) > 0
+ documentChanges: WorkspaceEditWithDocumentChanges = (
+ _rope_changeset_to_workspace_edit(
+ workspace,
+ rope_changeset,
+ )
+ )
+ workspace_edit: dict = {}
+ if "changes" in workspace_edit_format:
+ changes: WorkspaceEditWithChanges = (
+ convert_workspace_edit_document_changes_to_changes(documentChanges)
+ )
+ workspace_edit.update(changes)
+ if "documentChanges" in workspace_edit_format:
+ workspace_edit.update(documentChanges)
+ return cast(WorkspaceEdit, workspace_edit)
+
+
+def apply_rope_changeset(
+ workspace,
+ rope_changeset: rope.ChangeSet,
+ workspace_edit_format: List[WorkspaceEditFormat] =
DEFAULT_WORKSPACE_EDIT_FORMAT,
+) -> None:
workspace_edit = rope_changeset_to_workspace_edit(
workspace,
rope_changeset,
+ workspace_edit_format=workspace_edit_format,
)
logger.info("applying workspace edit: %s", workspace_edit)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/pylsp_rope/refactoring.py
new/pylsp-rope-0.1.15/pylsp_rope/refactoring.py
--- old/pylsp-rope-0.1.11/pylsp_rope/refactoring.py 2023-01-17
07:48:42.000000000 +0100
+++ new/pylsp-rope-0.1.15/pylsp_rope/refactoring.py 2024-03-12
04:29:02.000000000 +0100
@@ -1,6 +1,6 @@
import ast
+from typing import List, Optional
-from rope.base import evaluate
from rope.contrib import generate
from rope.refactor import (
extract,
@@ -14,10 +14,12 @@
from pylsp_rope import typing, commands
from pylsp_rope.project import (
+ WorkspaceEditFormat,
get_project,
get_resource,
get_resources,
apply_rope_changeset,
+ DEFAULT_WORKSPACE_EDIT_FORMAT,
)
from pylsp_rope.typing import DocumentUri, CodeActionKind
@@ -32,10 +34,20 @@
self.arguments = arguments
self.__dict__.update(**arguments)
- def __call__(self):
+ def __call__(
+ self,
+ *,
+ workspace_edit_format: List[
+ WorkspaceEditFormat
+ ] = DEFAULT_WORKSPACE_EDIT_FORMAT,
+ ):
rope_changeset = self.get_changes()
if rope_changeset is not None:
- apply_rope_changeset(self.workspace, rope_changeset)
+ apply_rope_changeset(
+ self.workspace,
+ rope_changeset,
+ workspace_edit_format,
+ )
def get_changes(self):
"""
@@ -232,6 +244,7 @@
kind: CodeActionKind = "refactor"
document_uri: DocumentUri
+ documents: Optional[List[DocumentUri]] = None
position: typing.Range
def validate(self, info):
@@ -249,8 +262,13 @@
resource=resource,
offset=current_document.offset_at_position(self.position),
)
+ resources = (
+ get_resources(self.workspace, self.documents)
+ if self.documents is not None
+ else None
+ )
rope_changeset = refactoring.get_changes(
- resources=get_resources(self.workspace, getattr(self, "documents",
None)),
+ resources=resources,
)
return rope_changeset
@@ -358,6 +376,7 @@
Given an undefined symbol under cursor, generate an empty
variable/function/class/module/package
"""
+
name = commands.COMMAND_GENERATE_CODE
kind: CodeActionKind = "quickfix"
@@ -393,5 +412,6 @@
document_uri=document.uri,
position=position,
generate_kind=generate_kind,
- ) for generate_kind in ["variable", "function", "class", "module",
"package"]
+ )
+ for generate_kind in ["variable", "function", "class", "module",
"package"]
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/pylsp_rope/text.py
new/pylsp-rope-0.1.15/pylsp_rope/text.py
--- old/pylsp-rope-0.1.11/pylsp_rope/text.py 2021-10-12 04:04:46.000000000
+0200
+++ new/pylsp-rope-0.1.15/pylsp_rope/text.py 2024-03-12 04:29:02.000000000
+0100
@@ -23,8 +23,7 @@
line: Tuple[AutoLineNumber, Optional[_CharNumberOrMarker]],
*,
_default_character: _CharNumberOrMarker = CharNumber(0),
-) -> typing.Position:
- ...
+) -> typing.Position: ...
@overload
@@ -32,24 +31,21 @@
line: AutoLineNumber,
*,
_default_character: _CharNumberOrMarker = CharNumber(0),
-) -> typing.Position:
- ...
+) -> typing.Position: ...
@overload
def Position(
line: AutoLineNumber,
character: AutoCharNumber,
-) -> typing.Position:
- ...
+) -> typing.Position: ...
@overload
def Position(
line: AutoLineNumber,
character: Literal["^", "$"],
-) -> typing.Position:
- ...
+) -> typing.Position: ...
def Position(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/pylsp_rope/typing.py
new/pylsp-rope-0.1.15/pylsp_rope/typing.py
--- old/pylsp-rope-0.1.11/pylsp_rope/typing.py 2021-11-04 03:25:31.000000000
+0100
+++ new/pylsp-rope-0.1.15/pylsp_rope/typing.py 2024-03-12 04:29:02.000000000
+0100
@@ -1,5 +1,9 @@
import sys
-from typing import List, Dict, Optional, NewType, Any
+from typing import List, Dict, Optional, NewType, Any, Union
+try:
+ from typing import TypeGuard
+except ImportError:
+ from typing_extensions import TypeGuard
if sys.version_info >= (3, 8):
@@ -25,17 +29,54 @@
end: Position
+class TextDocumentIdentifier(TypedDict):
+ uri: DocumentUri
+
+
+class OptionalVersionedTextDocumentIdentifier(TextDocumentIdentifier):
+ version: Optional[int]
+
+
class TextEdit(TypedDict):
range: Range
newText: str
-class WorkspaceEdit(TypedDict):
- changes: Optional[Dict[DocumentUri, List[TextEdit]]]
- # documentChanges: ...
+class TextDocumentEdit(TypedDict):
+ textDocument: OptionalVersionedTextDocumentIdentifier
+
+ edits: List[TextEdit] # FIXME: should be: list[TextEdit|
AnnotatedTextEdit]
+
+
+class WorkspaceEditWithChanges(TypedDict):
+ changes: Dict[DocumentUri, List[TextEdit]]
+ # documentChanges: Optional[list[TextDocumentEdit]] # FIXME: should be:
(TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]
+ # changeAnnotations: ...
+
+
+class WorkspaceEditWithDocumentChanges(TypedDict):
+ # changes: Optional[Dict[DocumentUri, List[TextEdit]]]
+ documentChanges: List[
+ TextDocumentEdit
+ ] # FIXME: should be: (TextDocumentEdit | CreateFile | RenameFile |
DeleteFile)[]
# changeAnnotations: ...
+WorkspaceEdit = Union[WorkspaceEditWithChanges,
WorkspaceEditWithDocumentChanges]
+
+
+def is_workspace_edit_with_changes(
+ workspace_edit: WorkspaceEdit,
+) -> TypeGuard[WorkspaceEditWithChanges]:
+ return "changes" in workspace_edit
+
+
+def is_workspace_edit_with_document_changes(
+ workspace_edit: WorkspaceEdit,
+) -> TypeGuard[WorkspaceEditWithDocumentChanges]:
+ return "documentChanges" in workspace_edit
+
+
class ApplyWorkspaceEditParams(TypedDict):
label: Optional[str]
edit: WorkspaceEdit
@@ -79,9 +120,3 @@
Line = NewType("Line", str)
LineNumber = NewType("LineNumber", int)
CharNumber = NewType("CharNumber", int)
-
-
-class SimpleWorkspaceEdit(TypedDict):
- """This is identical to WorkspaceEdit, but `changes` field is not
optional."""
-
- changes: Dict[DocumentUri, List[TextEdit]]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/pylsp_rope.egg-info/PKG-INFO
new/pylsp-rope-0.1.15/pylsp_rope.egg-info/PKG-INFO
--- old/pylsp-rope-0.1.11/pylsp_rope.egg-info/PKG-INFO 2023-01-17
08:06:05.000000000 +0100
+++ new/pylsp-rope-0.1.15/pylsp_rope.egg-info/PKG-INFO 2024-03-12
04:29:08.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pylsp-rope
-Version: 0.1.11
+Version: 0.1.15
Summary: Extended refactoring capabilities for Python LSP Server using Rope.
Home-page: https://github.com/python-rope/pylsp-rope
Author: Lie Ryan
@@ -15,10 +15,17 @@
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.6
Description-Content-Type: text/markdown
-Provides-Extra: dev
-Provides-Extra: test
License-File: LICENSE
License-File: AUTHORS.txt
+Requires-Dist: python-lsp-server
+Requires-Dist: rope>=0.21.0
+Requires-Dist: typing-extensions; python_version < "3.10"
+Provides-Extra: dev
+Requires-Dist: build; extra == "dev"
+Requires-Dist: pytest; extra == "dev"
+Requires-Dist: twine; extra == "dev"
+Provides-Extra: test
+Requires-Dist: pytest; extra == "test"
# pylsp-rope
@@ -158,9 +165,15 @@
See
[CONTRIBUTING.md](https://github.com/python-rope/pylsp-rope/blob/main/CONTRIBUTING.md).
+## Packaging status
+
+[](https://repology.org/project/python:pylsp-rope/versions)
+
+[](https://repology.org/project/python:lsp-rope/versions)
+
## Credits
This package was created with
[Cookiecutter](https://github.com/audreyr/cookiecutter) from
-[lieryan/cookiecutter-pylsp-plugin](https://github.com/lieryan/cookiecutter-pylsp-plugin)
+[python-lsp/cookiecutter-pylsp-plugin](https://github.com/python-lsp/cookiecutter-pylsp-plugin)
project template.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/pylsp_rope.egg-info/requires.txt
new/pylsp-rope-0.1.15/pylsp_rope.egg-info/requires.txt
--- old/pylsp-rope-0.1.11/pylsp_rope.egg-info/requires.txt 2023-01-17
08:06:05.000000000 +0100
+++ new/pylsp-rope-0.1.15/pylsp_rope.egg-info/requires.txt 2024-03-12
04:29:08.000000000 +0100
@@ -1,7 +1,7 @@
python-lsp-server
rope>=0.21.0
-[:python_version < "3.8"]
+[:python_version < "3.10"]
typing-extensions
[dev]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/pyproject.toml
new/pylsp-rope-0.1.15/pyproject.toml
--- old/pylsp-rope-0.1.11/pyproject.toml 2023-01-17 07:12:37.000000000
+0100
+++ new/pylsp-rope-0.1.15/pyproject.toml 2024-03-12 04:29:02.000000000
+0100
@@ -3,7 +3,7 @@
[tool.mypy]
-python_version = "3.6"
+python_version = "3.8"
warn_return_any = true
warn_unused_configs = true
ignore_missing_imports = true
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/setup.cfg
new/pylsp-rope-0.1.15/setup.cfg
--- old/pylsp-rope-0.1.11/setup.cfg 2023-01-17 08:06:05.202077000 +0100
+++ new/pylsp-rope-0.1.15/setup.cfg 2024-03-12 04:29:09.012215900 +0100
@@ -1,6 +1,6 @@
[metadata]
name = pylsp-rope
-version = 0.1.11
+version = 0.1.15
author = Lie Ryan
author_email = [email protected]
url = https://github.com/python-rope/pylsp-rope
@@ -22,7 +22,7 @@
install_requires =
python-lsp-server
rope>=0.21.0
- typing-extensions; python_version < '3.8'
+ typing-extensions; python_version < '3.10'
python_requires = >= 3.6
[options.packages.find]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/test/conftest.py
new/pylsp-rope-0.1.15/test/conftest.py
--- old/pylsp-rope-0.1.11/test/conftest.py 2023-01-17 04:51:09.000000000
+0100
+++ new/pylsp-rope-0.1.15/test/conftest.py 2024-03-12 04:29:02.000000000
+0100
@@ -1,7 +1,12 @@
from pathlib import Path
from unittest.mock import Mock
-import pkg_resources
+try:
+ from importlib.resources import files as resources_files
+except ImportError:
+ resources_files = None
+ import pkg_resources
+
import pytest
from pylsp import uris
from pylsp.config.config import Config
@@ -59,7 +64,10 @@
def read_fixture_file(name):
- return pkg_resources.resource_string(__name__, "fixtures/" + name).decode()
+ if resources_files:
+ return (resources_files("test") / f"fixtures/{name}").read_text()
+ else:
+ return pkg_resources.resource_string(__name__, "fixtures/" +
name).decode()
def create_document(workspace, name):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pylsp-rope-0.1.11/test/fixtures/undefined_variable.py
new/pylsp-rope-0.1.15/test/fixtures/undefined_variable.py
--- old/pylsp-rope-0.1.11/test/fixtures/undefined_variable.py 2023-01-17
02:36:24.000000000 +0100
+++ new/pylsp-rope-0.1.15/test/fixtures/undefined_variable.py 2024-03-12
04:29:02.000000000 +0100
@@ -1,2 +1,2 @@
def foo():
- print(undef_var)
+ print(undef_var) # noqa: F821
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/test/helpers.py
new/pylsp-rope-0.1.15/test/helpers.py
--- old/pylsp-rope-0.1.11/test/helpers.py 2021-11-06 08:59:23.000000000
+0100
+++ new/pylsp-rope-0.1.15/test/helpers.py 2024-03-12 04:29:02.000000000
+0100
@@ -11,7 +11,7 @@
CodeAction,
DocumentContent,
DocumentUri,
- SimpleWorkspaceEdit,
+ WorkspaceEditWithChanges,
TextEdit,
)
from test.conftest import read_fixture_file
@@ -49,7 +49,7 @@
return document_edits
-def assert_is_apply_edit_request(edit_request: Any) -> SimpleWorkspaceEdit:
+def assert_is_apply_edit_request(edit_request: Any) ->
WorkspaceEditWithChanges:
assert edit_request == call(
"workspace/applyEdit",
{
@@ -59,7 +59,7 @@
},
)
- workspace_edit: SimpleWorkspaceEdit = edit_request[0][1]["edit"]
+ workspace_edit: WorkspaceEditWithChanges = edit_request[0][1]["edit"]
for document_uri, document_edits in workspace_edit["changes"].items():
assert is_document_uri(document_uri)
for change in document_edits:
@@ -79,14 +79,14 @@
def assert_modified_documents(
- workspace_edit: SimpleWorkspaceEdit,
+ workspace_edit: WorkspaceEditWithChanges,
document_uris: Collection[DocumentUri],
) -> None:
assert workspace_edit["changes"].keys() == set(document_uris)
def assert_unmodified_document(
- workspace_edit: SimpleWorkspaceEdit,
+ workspace_edit: WorkspaceEditWithChanges,
document_uri: DocumentUri,
) -> None:
assert is_document_uri(document_uri)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pylsp-rope-0.1.11/test/test_project.py
new/pylsp-rope-0.1.15/test/test_project.py
--- old/pylsp-rope-0.1.11/test/test_project.py 2022-08-26 13:27:30.000000000
+0200
+++ new/pylsp-rope-0.1.15/test/test_project.py 2024-03-12 04:29:02.000000000
+0100
@@ -5,44 +5,74 @@
get_resource,
rope_changeset_to_workspace_edit,
)
+from pylsp_rope.typing import (
+ is_workspace_edit_with_changes,
+ is_workspace_edit_with_document_changes,
+)
from test.conftest import create_document
-def test_rope_changeset_to_workspace_changeset(workspace):
+EXPECTED_EDITS = [
+ {
+ "range": {
+ "start": {"line": 2, "character": 0},
+ "end": {"line": 3, "character": 0},
+ },
+ "newText": "",
+ },
+ {
+ "range": {
+ "start": {"line": 4, "character": 0},
+ "end": {"line": 5, "character": 0},
+ },
+ "newText": 'print("world")\n',
+ },
+ {
+ "range": {
+ "start": {"line": 15, "character": 0},
+ "end": {"line": 16, "character": 0},
+ },
+ "newText": ' os.path.join("world", roses)\n',
+ },
+]
+
+
+def test_rope_changeset_to_workspace_changeset_changes(workspace):
document = create_document(workspace, "many_changes.py")
rope_changeset = get_rope_changeset(workspace, document)
workspace_edit = rope_changeset_to_workspace_edit(
workspace,
rope_changeset,
+ workspace_edit_format=["changes"],
)
+ assert is_workspace_edit_with_changes(workspace_edit)
assert workspace_edit["changes"] == {
- document.uri: [
- {
- "range": {
- "start": {"line": 2, "character": 0},
- "end": {"line": 3, "character": 0},
- },
- "newText": "",
- },
- {
- "range": {
- "start": {"line": 4, "character": 0},
- "end": {"line": 5, "character": 0},
- },
- "newText": 'print("world")\n',
- },
- {
- "range": {
- "start": {"line": 15, "character": 0},
- "end": {"line": 16, "character": 0},
- },
- "newText": ' os.path.join("world", roses)\n',
- },
- ]
+ document.uri: EXPECTED_EDITS,
}
+def test_rope_changeset_to_workspace_changeset_document_changes(workspace):
+ document = create_document(workspace, "many_changes.py")
+ rope_changeset = get_rope_changeset(workspace, document)
+ workspace_edit = rope_changeset_to_workspace_edit(
+ workspace,
+ rope_changeset,
+ workspace_edit_format=["documentChanges"],
+ )
+
+ assert is_workspace_edit_with_document_changes(workspace_edit)
+ assert workspace_edit["documentChanges"] == [
+ {
+ "textDocument": {
+ "uri": document.uri,
+ "version": None,
+ },
+ "edits": EXPECTED_EDITS,
+ },
+ ]
+
+
def get_rope_changeset(workspace, document):
_, resource = get_resource(workspace, document.uri)
offset = document.source.index("hello = ")