Skip to content

Commit e235a4b

Browse files
committed
refactor: extract venv management code into its own class (#146)
1 parent 8483613 commit e235a4b

24 files changed

+202
-141
lines changed

.github/workflows/on-pull-request.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
- uses: SublimeText/UnitTesting/actions/setup@v1
3131
with:
3232
sublime-text-version: 4
33+
# Needs to have different name than the dependency to be able to run tests
34+
package-name: lsp-utils-dep
3335
extra-packages: |
3436
sublimelsp/LSP@main
3537
sublimelsp/LSP-pyright@master
@@ -52,9 +54,9 @@ jobs:
5254
cd ./
5355
# detached head will crash package control
5456
rm -rf "./.git"
55-
echo "Overwriting installed dependency in $ST_LIBS_DIR/$PACKAGE"
56-
rm -rf "$ST_LIBS_DIR/$PACKAGE"
57-
mv "./st4_py38/$PACKAGE" "$ST_LIBS_DIR"
57+
echo "Overwriting installed dependency in $ST_LIBS_DIR/lsp_utils"
58+
rm -rf "$ST_LIBS_DIR/lsp_utils"
59+
mv "./st4_py38/lsp_utils" "$ST_LIBS_DIR"
5860
cd -
5961
- uses: SublimeText/UnitTesting/actions/run-tests@v1
6062

@@ -70,7 +72,7 @@ jobs:
7072
- run: |
7173
sudo apt update
7274
sudo apt install --no-install-recommends -y x11-xserver-utils
73-
- run: pip3 install mypy==1.7.1 flake8==5.0.4 pyright==1.1.339 --user
75+
- run: pip3 install mypy==1.19.1 flake8==7.3.0 pyright==1.1.408 --user
7476
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
7577
- run: git clone https://github.com/sublimelsp/LSP.git
7678
- run: git clone https://github.com/SublimeText/sublime_lib.git

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ python_version = 3.11
44
# check_untyped_defs = True
55
disallow_untyped_defs = True
66
strict_optional = True
7-
mypy_path = ..:../LSP/stubs:../sublime_lib/st3/
7+
mypy_path = ..:../LSP/stubs:../sublime_lib/
88
namespace_packages = True
99
; Don't report errors in external packages.
1010
follow_imports = silent

pyrightconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"pythonVersion": "3.11",
2+
"pythonVersion": "3.8",
33
"reportMissingModuleSource": "none",
4+
"reportUnusedCallResult": "none",
45
"ignore": ["**/third_party/"],
5-
"extraPaths": ["..", "../LSP/stubs", "../sublime_lib/st3"]
6+
"extraPaths": ["..", "../LSP/stubs", "../sublime_lib"]
67
}

st4_py38/lsp_utils/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from ._client_handler import ClientHandler
23
from ._client_handler import notification_handler
34
from ._client_handler import request_handler
@@ -6,6 +7,7 @@
67
from .generic_client_handler import GenericClientHandler
78
from .node_runtime import NodeRuntime
89
from .npm_client_handler import NpmClientHandler
10+
from .pip_venv_manager import PipVenvManager
911
from .server_npm_resource import ServerNpmResource
1012
from .server_pip_resource import ServerPipResource
1113
from .server_resource_interface import ServerResourceInterface
@@ -18,6 +20,7 @@
1820
'GenericClientHandler',
1921
'NodeRuntime',
2022
'NpmClientHandler',
23+
'PipVenvManager',
2124
'ServerResourceInterface',
2225
'ServerStatus',
2326
'ServerNpmResource',

st4_py38/lsp_utils/_client_handler/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from .abstract_plugin import ClientHandler
23
from .api_decorator import notification_handler
34
from .api_decorator import request_handler

st4_py38/lsp_utils/_client_handler/abstract_plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from .._util import weak_method
23
from ..api_wrapper_interface import ApiWrapperInterface
34
from ..server_resource_interface import ServerStatus
@@ -14,8 +15,8 @@
1415
from LSP.plugin import unregister_plugin
1516
from LSP.plugin import WorkspaceFolder
1617
from LSP.plugin.core.rpc import method2attr
17-
from LSP.plugin.core.typing import Any, Callable, Dict, List, Optional, Tuple, TypedDict
1818
from os import path
19+
from typing import Any, Callable, Dict, List, Optional, Tuple, TypedDict
1920
from weakref import ref
2021
import sublime
2122

st4_py38/lsp_utils/_client_handler/api_decorator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from __future__ import annotations
12
from ..api_wrapper_interface import ApiWrapperInterface
23
from .interface import ClientHandlerInterface
3-
from LSP.plugin.core.typing import Any, Callable, List, Optional, TypeVar, Union
4+
from typing import Any, Callable, List, Optional, TypeVar, Union
45
import inspect
56

67
__all__ = [
@@ -72,7 +73,7 @@ def register_decorated_handlers(client_handler: ClientHandlerInterface, api: Api
7273
"""
7374
for _, func in inspect.getmembers(client_handler, predicate=inspect.isroutine):
7475
for client_event, handler_mark in _HANDLER_MARKS.items():
75-
message_methods = getattr(func, handler_mark, None) # type: Optional[List[str]]
76+
message_methods: Optional[List[str]] = getattr(func, handler_mark, None)
7677
if message_methods is None:
7778
continue
7879

st4_py38/lsp_utils/_client_handler/interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from __future__ import annotations
12
from ..api_wrapper_interface import ApiWrapperInterface
23
from ..server_resource_interface import ServerResourceInterface
34
from abc import ABCMeta
45
from abc import abstractmethod
56
from LSP.plugin import ClientConfig
67
from LSP.plugin import DottedDict
78
from LSP.plugin import WorkspaceFolder
8-
from LSP.plugin.core.typing import Dict, List, Optional, Tuple
9+
from typing import Dict, List, Optional, Tuple
910
import sublime
1011

1112
__all__ = ['ClientHandlerInterface']

st4_py38/lsp_utils/_util/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from .weak_method import weak_method
23

34
__all__ = [

st4_py38/lsp_utils/_util/weak_method.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from LSP.plugin.core.typing import Any, Callable
1+
from __future__ import annotations
22
from types import MethodType
3+
from typing import Any, Callable
34
import weakref
45

56

0 commit comments

Comments
 (0)