Skip to content

Commit e078d3b

Browse files
committed
passes all tests, minor modifications to vsc ext code
1 parent 4a0abd5 commit e078d3b

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

codeflash/code_utils/edit_generated_tests.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def __init__(self, qualifed_name: str, source_code: str) -> None:
5555
self.name = qualifed_name.split(".")[-1]
5656
self.results: list[int] = [] # map actual line number to line number in ast
5757

58-
def visit_Call(self, node): # noqa: ANN201, ANN001
58+
def visit_Call(self, node): # type: ignore[no-untyped-def] # noqa: ANN201, ANN001
5959
"""Detect fn calls."""
60-
func_name = self._get_called_func_name(node.func)
60+
func_name = self._get_called_func_name(node.func) # type: ignore[no-untyped-call]
6161
if func_name == self.name:
6262
self.results.append(node.lineno - 1)
6363
self.generic_visit(node)
6464

65-
def _get_called_func_name(self, node): # noqa: ANN001, ANN202
65+
def _get_called_func_name(self, node): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202
6666
"""Return name of called fn."""
6767
if isinstance(node, ast.Name):
6868
return node.id
@@ -130,10 +130,12 @@ def leave_FunctionDef(self, original_node: cst.FunctionDef, updated_node: cst.Fu
130130
return updated_node
131131

132132
def leave_SimpleStatementLine(
133-
self, original_node: cst.SimpleStatementLine, updated_node: cst.SimpleStatementLine
133+
self,
134+
original_node: cst.SimpleStatementLine, # noqa: ARG002
135+
updated_node: cst.SimpleStatementLine,
134136
) -> cst.SimpleStatementLine:
135137
# Check if this statement line contains a call to self.name
136-
if self._contains_myfunc_call(updated_node):
138+
if self._contains_myfunc_call(updated_node): # type: ignore[no-untyped-call]
137139
# Find matching test cases by looking for this test function name in the test results
138140
self.cfo_idx_loc_to_look_at += 1
139141
matching_original_times = []
@@ -209,21 +211,21 @@ def leave_SimpleStatementLine(
209211
)
210212
return updated_node
211213

212-
def _contains_myfunc_call(self, node):
214+
def _contains_myfunc_call(self, node): # type: ignore[no-untyped-def] # noqa : ANN202, ANN001
213215
"""Recursively search for any Call node in the statement whose function is named self.name (including obj.myfunc)."""
214216

215217
class Finder(cst.CSTVisitor):
216-
def __init__(self, name: str):
218+
def __init__(self, name: str) -> None:
217219
super().__init__()
218220
self.found = False
219221
self.name = name
220222

221-
def visit_Call(self, call_node):
223+
def visit_Call(self, call_node) -> None: # type: ignore[no-untyped-def] # noqa : ANN001
222224
func_expr = call_node.func
223225
if isinstance(func_expr, cst.Name):
224226
if func_expr.value == self.name:
225227
self.found = True
226-
elif isinstance(func_expr, cst.Attribute):
228+
elif isinstance(func_expr, cst.Attribute): # noqa : SIM102
227229
if func_expr.attr.value == self.name:
228230
self.found = True
229231

codeflash/lsp/server.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pathlib import Path
44
from typing import TYPE_CHECKING, Any
55

6-
from lsprotocol.types import INITIALIZE, MessageType, LogMessageParams
6+
from lsprotocol.types import INITIALIZE, LogMessageParams, MessageType
77
from pygls import uris
88
from pygls.protocol import LanguageServerProtocol, lsp_method
99
from pygls.server import LanguageServer
@@ -58,21 +58,22 @@ def initialize_optimizer(self, config_file: Path) -> None:
5858

5959
def show_message_log(self, message: str, message_type: str) -> None:
6060
"""Send a log message to the client's output channel.
61-
61+
6262
Args:
6363
message: The message to log
6464
message_type: String type - "Info", "Warning", "Error", or "Log"
65+
6566
"""
6667
# Convert string message type to LSP MessageType enum
6768
type_mapping = {
6869
"Info": MessageType.Info,
69-
"Warning": MessageType.Warning,
70+
"Warning": MessageType.Warning,
7071
"Error": MessageType.Error,
71-
"Log": MessageType.Log
72+
"Log": MessageType.Log,
7273
}
73-
74+
7475
lsp_message_type = type_mapping.get(message_type, MessageType.Info)
75-
76+
7677
# Send log message to client (appears in output channel)
7778
log_params = LogMessageParams(type=lsp_message_type, message=message)
7879
self.lsp.notify("window/logMessage", log_params)

codeflash/lsp/server_entry.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""This script is the dedicated entry point for the Codeflash Language Server.
1+
"""The following script is the dedicated entry point for the Codeflash Language Server.
2+
23
It initializes the server and redirects its logs to stderr so that the
34
VS Code client can display them in the output channel.
45
@@ -13,7 +14,7 @@
1314

1415

1516
# Configure logging to stderr for VS Code output channel
16-
def setup_logging():
17+
def setup_logging(): # noqa : ANN201
1718
# Clear any existing handlers to prevent conflicts
1819
root_logger = logging.getLogger()
1920
root_logger.handlers.clear()

0 commit comments

Comments
 (0)