Skip to content

Commit 85d0ca9

Browse files
authored
Revert "Add typing to public methods"
1 parent d5b15dd commit 85d0ca9

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

pylspclient/json_rpc_endpoint.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import json
33
from pylspclient.lsp_errors import ErrorCodes, ResponseError
44
import threading
5-
from typing import BinaryIO
65

76
JSON_RPC_REQ_FORMAT = "Content-Length: {json_string_len}\r\n\r\n{json_string}"
87
LEN_HEADER = "Content-Length: "
@@ -16,7 +15,7 @@ class MyEncoder(json.JSONEncoder):
1615
"""
1716
Encodes an object in JSON
1817
"""
19-
def default(self, o: object): # pylint: disable=E0202
18+
def default(self, o): # pylint: disable=E0202
2019
return o.__dict__
2120

2221

@@ -25,14 +24,14 @@ class JsonRpcEndpoint(object):
2524
Thread safe JSON RPC endpoint implementation. Responsible to recieve and send JSON RPC messages, as described in the
2625
protocol. More information can be found: https://www.jsonrpc.org/
2726
'''
28-
def __init__(self, stdin: BinaryIO, stdout: BinaryIO):
27+
def __init__(self, stdin, stdout):
2928
self.stdin = stdin
3029
self.stdout = stdout
3130
self.read_lock = threading.Lock()
3231
self.write_lock = threading.Lock()
3332

3433
@staticmethod
35-
def __add_header(json_string: str) -> str:
34+
def __add_header(json_string):
3635
'''
3736
Adds a header for the given json string
3837
@@ -42,7 +41,7 @@ def __add_header(json_string: str) -> str:
4241
return JSON_RPC_REQ_FORMAT.format(json_string_len=len(json_string), json_string=json_string)
4342

4443

45-
def send_request(self, message: any) -> None:
44+
def send_request(self, message):
4645
'''
4746
Sends the given message.
4847
@@ -55,7 +54,7 @@ def send_request(self, message: any) -> None:
5554
self.stdin.flush()
5655

5756

58-
def recv_response(self) -> any:
57+
def recv_response(self):
5958
'''
6059
Recives a message.
6160

pylspclient/lsp_client.py

+2-13
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,7 @@ def __init__(self, lsp_endpoint: LspEndpoint):
1515
self.lsp_endpoint = lsp_endpoint
1616

1717

18-
def initialize(
19-
self,
20-
processId: Optional[int] = None,
21-
rootPath: Optional[str] = None,
22-
rootUri: Optional[str] = None,
23-
initializationOptions: any = None,
24-
capabilities: dict = None,
25-
trace: Optional[str] = None,
26-
workspaceFolders: Optional[list] = None
27-
) -> any:
18+
def initialize(self, processId, rootPath, rootUri, initializationOptions, capabilities, trace, workspaceFolders):
2819
"""
2920
The initialize request is sent as the first request from the client to the server. If the server receives a request or notification
3021
before the initialize request it should act as follows:
@@ -42,16 +33,14 @@ def initialize(
4233
:param int processId: The process Id of the parent process that started the server. Is null if the process has not been started by another process.
4334
If the parent process is not alive then the server should exit (see exit notification) its process.
4435
:param str rootPath: The rootPath of the workspace. Is null if no folder is open. Deprecated in favour of rootUri.
45-
:param str rootUri: The rootUri of the workspace. Is null if no folder is open. If both `rootPath` and `rootUri` are set
36+
:param DocumentUri rootUri: The rootUri of the workspace. Is null if no folder is open. If both `rootPath` and `rootUri` are set
4637
`rootUri` wins.
4738
:param any initializationOptions: User provided initialization options.
4839
:param ClientCapabilities capabilities: The capabilities provided by the client (editor or tool).
4940
:param Trace trace: The initial trace setting. If omitted trace is disabled ('off').
5041
:param list workspaceFolders: The workspace folders configured in the client when the server starts. This property is only available if the client supports workspace folders.
5142
It can be `null` if the client supports workspace folders but none are configured.
5243
"""
53-
if not capabilities:
54-
raise ValueError("capabilities must be provided")
5544
self.lsp_endpoint.start()
5645
return self.lsp_endpoint.call_method("initialize", processId=processId, rootPath=rootPath, rootUri=rootUri, initializationOptions=initializationOptions, capabilities=capabilities, trace=trace, workspaceFolders=workspaceFolders)
5746

pylspclient/lsp_endpoint.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
from __future__ import print_function
22
import threading
33
from pylspclient.lsp_errors import ErrorCodes, ResponseError
4-
from pylspclient import JsonRpcEndpoint
5-
from typing import Dict, Callable, Any, Union
64

75

86
class LspEndpoint(threading.Thread):
9-
def __init__(
10-
self,
11-
json_rpc_endpoint: JsonRpcEndpoint,
12-
method_callbacks: Dict[str, Callable[[Any], Any]]={},
13-
notify_callbacks: Dict[str, Callable[[Any], Any]]={},
14-
timeout: int=2
15-
):
7+
def __init__(self, json_rpc_endpoint, method_callbacks={}, notify_callbacks={}, timeout=2):
168
threading.Thread.__init__(self)
179
self.json_rpc_endpoint = json_rpc_endpoint
1810
self.notify_callbacks = notify_callbacks
@@ -32,7 +24,7 @@ def handle_result(self, rpc_id, result, error):
3224
cond.release()
3325

3426

35-
def stop(self) -> None:
27+
def stop(self):
3628
self.shutdown_flag = True
3729

3830

@@ -43,11 +35,11 @@ def run(self):
4335
if jsonrpc_message is None:
4436
print("server quit")
4537
break
46-
method: str = jsonrpc_message.get("method")
47-
result: any = jsonrpc_message.get("result")
48-
error: dict = jsonrpc_message.get("error")
49-
rpc_id: Union[str, int] = jsonrpc_message.get("id")
50-
params: Union[dict, list] = jsonrpc_message.get("params")
38+
method = jsonrpc_message.get("method")
39+
result = jsonrpc_message.get("result")
40+
error = jsonrpc_message.get("error")
41+
rpc_id = jsonrpc_message.get("id")
42+
params = jsonrpc_message.get("params")
5143

5244
if method:
5345
if rpc_id:
@@ -80,7 +72,7 @@ def send_response(self, id, result, error):
8072
self.json_rpc_endpoint.send_request(message_dict)
8173

8274

83-
def send_message(self, method_name: str, params: dict, id: int=None):
75+
def send_message(self, method_name, params, id = None):
8476
message_dict = {}
8577
message_dict["jsonrpc"] = "2.0"
8678
if id is not None:

0 commit comments

Comments
 (0)