Skip to content

Commit c6d86c8

Browse files
authored
Merge pull request #1145 from codeflash-ai/jit-docs
Documentation for JIT support
2 parents f5a61fb + 5f74b14 commit c6d86c8

20 files changed

Lines changed: 402 additions & 39 deletions

File tree

codeflash/benchmarking/plugin/plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def get_benchmark_timings(trace_path: Path) -> dict[BenchmarkKey, int]:
200200

201201
# Pytest hooks
202202
@pytest.hookimpl
203-
def pytest_sessionfinish(self, session, exitstatus) -> None: # noqa: ANN001
203+
def pytest_sessionfinish(self, session, exitstatus) -> None:
204204
"""Execute after whole test run is completed."""
205205
# Write any remaining benchmark timings to the database
206206
codeflash_trace.close()
@@ -236,20 +236,20 @@ class Benchmark: # noqa: D106
236236
def __init__(self, request: pytest.FixtureRequest) -> None:
237237
self.request = request
238238

239-
def __call__(self, func, *args, **kwargs): # noqa: ANN001, ANN002, ANN003, ANN204
239+
def __call__(self, func, *args, **kwargs): # noqa: ANN002, ANN003, ANN204
240240
"""Handle both direct function calls and decorator usage."""
241241
if args or kwargs:
242242
# Used as benchmark(func, *args, **kwargs)
243243
return self._run_benchmark(func, *args, **kwargs)
244244

245245
# Used as @benchmark decorator
246-
def wrapped_func(*args, **kwargs): # noqa: ANN002, ANN003, ANN202
246+
def wrapped_func(*args, **kwargs): # noqa: ANN002, ANN003
247247
return func(*args, **kwargs)
248248

249249
self._run_benchmark(func)
250250
return wrapped_func
251251

252-
def _run_benchmark(self, func, *args, **kwargs): # noqa: ANN002, ANN003, ANN202
252+
def _run_benchmark(self, func, *args, **kwargs): # noqa: ANN002, ANN003
253253
"""Actual benchmark implementation."""
254254
node_path = getattr(self.request.node, "path", None) or getattr(self.request.node, "fspath", None)
255255
if node_path is None:

codeflash/cli_cmds/cmd_init.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,11 +1474,7 @@ def customize_codeflash_yaml_content(
14741474
return _customize_python_workflow_content(optimize_yml_content, git_root, benchmark_mode)
14751475

14761476

1477-
def _customize_python_workflow_content(
1478-
optimize_yml_content: str,
1479-
git_root: Path,
1480-
benchmark_mode: bool = False, # noqa: FBT001, FBT002
1481-
) -> str:
1477+
def _customize_python_workflow_content(optimize_yml_content: str, git_root: Path, benchmark_mode: bool = False) -> str:
14821478
"""Customize workflow content for Python projects."""
14831479
# Get dependency installation commands
14841480
toml_path = Path.cwd() / "pyproject.toml"
@@ -1513,11 +1509,7 @@ def _customize_python_workflow_content(
15131509

15141510

15151511
# TODO:{claude} Refactor and move to support for language specific
1516-
def _customize_js_workflow_content(
1517-
optimize_yml_content: str,
1518-
git_root: Path,
1519-
benchmark_mode: bool = False, # noqa: FBT001, FBT002
1520-
) -> str:
1512+
def _customize_js_workflow_content(optimize_yml_content: str, git_root: Path, benchmark_mode: bool = False) -> str:
15211513
"""Customize workflow content for JavaScript/TypeScript projects."""
15221514
from codeflash.cli_cmds.init_javascript import (
15231515
get_js_codeflash_install_step,

codeflash/cli_cmds/init_javascript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class JSSetupInfo:
6666

6767

6868
# Import theme from cmd_init to avoid duplication
69-
def _get_theme(): # noqa: ANN202
69+
def _get_theme():
7070
"""Get the CodeflashTheme - imported lazily to avoid circular imports."""
7171
from codeflash.cli_cmds.cmd_init import CodeflashTheme
7272

codeflash/code_utils/code_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def extract_unique_errors(pytest_output: str) -> set[str]:
436436
pattern = r"^E\s+(.*)$"
437437

438438
for error_message in re.findall(pattern, pytest_output, re.MULTILINE):
439-
error_message = error_message.strip() # noqa: PLW2901
439+
error_message = error_message.strip()
440440
if error_message:
441441
unique_errors.add(error_message)
442442

codeflash/code_utils/config_js.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def detect_module_root(project_root: Path, package_data: dict[str, Any]) -> str:
105105
return "."
106106

107107

108-
def detect_test_runner(project_root: Path, package_data: dict[str, Any]) -> str: # noqa: ARG001
108+
def detect_test_runner(project_root: Path, package_data: dict[str, Any]) -> str:
109109
"""Detect test runner from devDependencies or scripts.test.
110110
111111
Detection order:
@@ -144,7 +144,7 @@ def detect_test_runner(project_root: Path, package_data: dict[str, Any]) -> str:
144144
return "jest"
145145

146146

147-
def detect_formatter(project_root: Path, package_data: dict[str, Any]) -> list[str] | None: # noqa: ARG001
147+
def detect_formatter(project_root: Path, package_data: dict[str, Any]) -> list[str] | None:
148148
"""Detect formatter from devDependencies.
149149
150150
Detection order:

codeflash/code_utils/deduplicate_code.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414

1515

1616
def normalize_code(
17-
code: str,
18-
remove_docstrings: bool = True,
19-
return_ast_dump: bool = False,
20-
language: str | None = None,
17+
code: str, remove_docstrings: bool = True, return_ast_dump: bool = False, language: str | None = None
2118
) -> str:
2219
"""Normalize code by parsing, cleaning, and normalizing variable names.
2320

codeflash/code_utils/instrument_existing_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def find_and_update_line_node(
8989
# it's much more efficient to visit nodes manually. We'll only descend into expressions/statements.
9090

9191
# Helper for manual walk
92-
def iter_ast_calls(node): # noqa: ANN202
92+
def iter_ast_calls(node):
9393
# Generator to yield each ast.Call in test_node, preserves node identity
9494
stack = [node]
9595
while stack:
@@ -102,7 +102,7 @@ def iter_ast_calls(node): # noqa: ANN202
102102
if isinstance(value, list):
103103
for item in reversed(value):
104104
if isinstance(item, ast.AST):
105-
stack.append(item) # noqa: PERF401
105+
stack.append(item)
106106
elif isinstance(value, ast.AST):
107107
stack.append(value)
108108

codeflash/context/code_context_extractor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def build_testgen_context(
4646
helpers_of_fto_dict: dict[Path, set[FunctionSource]],
4747
helpers_of_helpers_dict: dict[Path, set[FunctionSource]],
4848
project_root_path: Path,
49-
remove_docstrings: bool, # noqa: FBT001
50-
include_imported_classes: bool, # noqa: FBT001
49+
remove_docstrings: bool,
50+
include_imported_classes: bool,
5151
) -> CodeStringsMarkdown:
5252
"""Build testgen context with optional imported class definitions and external base inits."""
5353
testgen_context = extract_code_markdown_context_from_files(

codeflash/languages/javascript/module_system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _get_relative_import_path(target_path: Path, source_path: Path) -> str:
185185

186186
def add_js_extension(module_path: str) -> str:
187187
"""Add .js extension to relative module paths for ESM compatibility."""
188-
if module_path.startswith(("./", "../")): # noqa: SIM102
188+
if module_path.startswith(("./", "../")):
189189
if not module_path.endswith(".js") and not module_path.endswith(".mjs"):
190190
return module_path + ".js"
191191
return module_path

codeflash/languages/javascript/support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ def instrument_source_for_line_profiler(
18721872
# Write instrumented code to source file
18731873
source_file_path.write_text(instrumented_source, encoding="utf-8")
18741874
logger.debug("Wrote instrumented source to %s", source_file_path)
1875-
return True # noqa: TRY300
1875+
return True
18761876
except Exception as e:
18771877
logger.warning("Failed to instrument source for line profiling: %s", e)
18781878
return False

0 commit comments

Comments
 (0)