Skip to content

Commit a09ff0b

Browse files
committed
fixed errors highlighted one line below, fixed .pysa files not being tracked by the server
1 parent ea2b235 commit a09ff0b

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

client/commands/v2/persistent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,14 @@ async def try_initialize(
196196
async def _read_lsp_request(
197197
input_channel: connection.TextReader, output_channel: connection.TextWriter
198198
) -> AsyncIterator[json_rpc.Request]:
199+
LOG.info("** Inside the read lsp function ** ")
199200
try:
201+
LOG.info("** Inside the try and except ** ")
200202
message = await lsp.read_json_rpc(input_channel)
203+
LOG.info(f"** {message} **")
201204
yield message
202205
except json_rpc.JSONRPCException as json_rpc_error:
206+
LOG.info("** Inside the except ** ")
203207
await lsp.write_json_rpc(
204208
output_channel,
205209
json_rpc.ErrorResponse(

client/commands/v2/pysa_server.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def wait_for_exit(self) -> int:
101101
async def process_open_request(
102102
self, parameters: lsp.DidOpenTextDocumentParameters
103103
) -> None:
104-
print("A document was just opened!")
104+
LOG.info("** Inside process_open_request() **")
105105
document_path = parameters.text_document.document_uri().to_file_path()
106106
if document_path is None:
107107
raise json_rpc.InvalidRequestError(
@@ -111,7 +111,7 @@ async def process_open_request(
111111
async def process_close_request(
112112
self, parameters: lsp.DidCloseTextDocumentParameters
113113
) -> None:
114-
print("A document was just closed!")
114+
LOG.info("** Inside process_close_request() **")
115115
document_path = parameters.text_document.document_uri().to_file_path()
116116
if document_path is None:
117117
raise json_rpc.InvalidRequestError(
@@ -126,7 +126,7 @@ async def process_close_request(
126126
async def process_did_save_request(
127127
self, parameters: lsp.DidSaveTextDocumentParameters
128128
) -> None:
129-
print("A document was just saved!")
129+
LOG.info("** Inside process_did_save_request() **")
130130
document_path = parameters.text_document.document_uri().to_file_path()
131131
if document_path is None:
132132
raise json_rpc.InvalidRequestError(
@@ -148,6 +148,7 @@ async def run(self) -> int:
148148
)
149149
return await self.wait_for_exit()
150150
elif request.method == "textDocument/didOpen":
151+
LOG.info("** A Document just opened! **")
151152
parameters = request.parameters
152153
if parameters is None:
153154
raise json_rpc.InvalidRequestError(
@@ -159,6 +160,7 @@ async def run(self) -> int:
159160
)
160161
)
161162
elif request.method == "textDocument/didClose":
163+
LOG.info("** A Document just closed! **")
162164
parameters = request.parameters
163165
if parameters is None:
164166
raise json_rpc.InvalidRequestError(
@@ -170,6 +172,7 @@ async def run(self) -> int:
170172
)
171173
)
172174
elif request.method == "textDocument/didSave":
175+
LOG.info("** A Document just saved! **")
173176
parameters = request.parameters
174177
if parameters is None:
175178
raise json_rpc.InvalidRequestError(
@@ -182,6 +185,8 @@ async def run(self) -> int:
182185
)
183186
elif request.id is not None:
184187
raise lsp.RequestCancelledError("Request not supported yet")
188+
else:
189+
LOG.info("** Hmmm I guess nothing seems to be happening **")
185190

186191

187192
async def run_persistent(
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) Facebook, Inc. and its affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
import subprocess
7+
8+
from django.http import HttpRequest, HttpResponse
9+
10+
def operate_on_twos(request: HttpRequest) -> HttpResponse:
11+
operator = request.POST["operator"]
12+
13+
result = eval(f"2 {operator} 2") # noqa: P204
14+
15+
return result
16+
17+
18+
def operate_on_threes(request: HttpRequest) -> HttpResponse:
19+
operator = request.GET["operator"]
20+
21+
exec(f"result = 3 {operator} 3")
22+
23+
return result # noqa: F82 1
24+
25+
def operate_on_fours(request: HttpRequest) -> HttpResponse:
26+
operator = request.GET["operator"]
27+
28+
result = subprocess.getoutput(f"expr 4 {operator} 4")
29+
30+
return result

0 commit comments

Comments
 (0)