mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
fix: lint issues in experiments folder and format fixes
This commit is contained in:
parent
e2fb3a50f2
commit
2f6a91f95d
7 changed files with 9 additions and 11 deletions
|
|
@ -240,9 +240,7 @@ class AiServiceClient:
|
||||||
n_candidates=n_candidates,
|
n_candidates=n_candidates,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_jit_rewritten_code(
|
def get_jit_rewritten_code(self, source_code: str, trace_id: str) -> list[OptimizedCandidate]:
|
||||||
self, source_code: str, trace_id: str
|
|
||||||
) -> list[OptimizedCandidate]:
|
|
||||||
"""Rewrite the given python code for performance via jit compilation by making a request to the Django endpoint.
|
"""Rewrite the given python code for performance via jit compilation by making a request to the Django endpoint.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
|
||||||
|
|
@ -613,8 +613,6 @@ class LanguageSupport(Protocol):
|
||||||
"""Parse line profiler output."""
|
"""Parse line profiler output."""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# === Test Execution ===
|
# === Test Execution ===
|
||||||
|
|
||||||
def run_behavioral_tests(
|
def run_behavioral_tests(
|
||||||
|
|
|
||||||
0
experiments/__init__.py
Normal file
0
experiments/__init__.py
Normal file
0
experiments/code_replacement/__init__.py
Normal file
0
experiments/code_replacement/__init__.py
Normal file
|
|
@ -18,6 +18,7 @@ Cons:
|
||||||
- Still text-based replacement (not AST rewriting)
|
- Still text-based replacement (not AST rewriting)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
@ -117,7 +118,7 @@ class HybridReplacer:
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def traverse(node):
|
def traverse(node) -> None: # noqa: ANN001
|
||||||
"""Recursively traverse tree to find functions."""
|
"""Recursively traverse tree to find functions."""
|
||||||
node_type = node.type
|
node_type = node.type
|
||||||
|
|
||||||
|
|
@ -246,7 +247,8 @@ class HybridReplacer:
|
||||||
boundaries = self.find_function_boundaries(source, function_name)
|
boundaries = self.find_function_boundaries(source, function_name)
|
||||||
|
|
||||||
if not boundaries:
|
if not boundaries:
|
||||||
raise ValueError(f"Function '{function_name}' not found in source")
|
msg = f"Function '{function_name}' not found in source"
|
||||||
|
raise ValueError(msg)
|
||||||
|
|
||||||
if len(boundaries) > 1:
|
if len(boundaries) > 1:
|
||||||
# Multiple functions with same name - use the first one
|
# Multiple functions with same name - use the first one
|
||||||
|
|
@ -368,7 +370,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
if not TREE_SITTER_AVAILABLE:
|
if not TREE_SITTER_AVAILABLE:
|
||||||
print("Cannot run tests: tree-sitter not installed")
|
print("Cannot run tests: tree-sitter not installed")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
replacer = HybridReplacer("javascript")
|
replacer = HybridReplacer("javascript")
|
||||||
ts_replacer = HybridReplacer("typescript")
|
ts_replacer = HybridReplacer("typescript")
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ def test_approach_a() -> ApproachSummary:
|
||||||
|
|
||||||
replacer = JsCodeshiftReplacer()
|
replacer = JsCodeshiftReplacer()
|
||||||
|
|
||||||
if not replacer._check_node_available():
|
if not replacer._check_node_available(): # noqa: SLF001
|
||||||
summary.available = False
|
summary.available = False
|
||||||
return summary
|
return summary
|
||||||
|
|
||||||
|
|
@ -235,7 +235,7 @@ def generate_report(summaries: list[ApproachSummary]) -> str:
|
||||||
return "\n".join(report)
|
return "\n".join(report)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> None:
|
||||||
"""Run all experiments and generate report."""
|
"""Run all experiments and generate report."""
|
||||||
print("=" * 70)
|
print("=" * 70)
|
||||||
print("Code Replacement Strategy Experiments")
|
print("Code Replacement Strategy Experiments")
|
||||||
|
|
|
||||||
|
|
@ -634,7 +634,7 @@ function last() {
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_test_cases():
|
def get_test_cases() -> list[ReplacementTestCase]:
|
||||||
"""Return all test cases."""
|
"""Return all test cases."""
|
||||||
return TEST_CASES
|
return TEST_CASES
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue