Skip to content

Commit 189fe12

Browse files
committed
linting
1 parent 0a296e2 commit 189fe12

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

codeflash/code_utils/code_replacer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ def visit_FunctionDef(self, node: cst.FunctionDef) -> bool:
265265
self.new_functions.append(node)
266266
return False
267267

268-
269268
def visit_ClassDef(self, node: cst.ClassDef) -> bool:
270269
if self.current_class:
271270
return False # If already in a class, do not recurse deeper
@@ -316,7 +315,6 @@ def leave_FunctionDef(self, original_node: cst.FunctionDef, updated_node: cst.Fu
316315

317316
return updated_node
318317

319-
320318
def visit_ClassDef(self, node: cst.ClassDef) -> bool:
321319
if self.current_class:
322320
return False # If already in a class, do not recurse deeper

codeflash/code_utils/coverage_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def extract_dependent_function(main_function: str, code_context: CodeOptimizatio
1414
"""Extract the single dependent function from the code context excluding the main function."""
1515
ast_tree = ast.parse(code_context.testgen_context_code)
1616

17-
dependent_functions = {node.name for node in ast_tree.body if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))}
17+
dependent_functions = {
18+
node.name for node in ast_tree.body if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))
19+
}
1820

1921
if main_function in dependent_functions:
2022
dependent_functions.discard(main_function)

codeflash/optimization/function_optimizer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,11 @@ def determine_best_candidate(
566566
tree = Tree(f"Candidate #{candidate_index} - Runtime Information")
567567
benchmark_tree = None
568568
if speedup_critic(
569-
candidate_result,
570-
original_code_baseline.runtime,
571-
None,
569+
candidate_result,
570+
original_code_baseline.runtime,
571+
None,
572572
self.function_to_optimize,
573-
original_baseline_results=original_code_baseline
573+
original_baseline_results=original_code_baseline,
574574
) and quantity_of_tests_critic(candidate_result):
575575
tree.add("This candidate is faster than the original code. 🚀") # TODO: Change this description
576576
tree.add(f"Original summed runtime: {humanize_runtime(original_code_baseline.runtime)}")

codeflash/result/critic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def async_speedup_critic(
9393
throughput_gain = (candidate_throughput - original_throughput) / original_throughput
9494
if throughput_gain > noise_floor:
9595
# Throughput improved above noise floor - accept optimization
96-
return True if best_runtime_until_now is None else candidate_result.best_test_runtime < best_runtime_until_now
96+
return (
97+
True if best_runtime_until_now is None else candidate_result.best_test_runtime < best_runtime_until_now
98+
)
9799

98100
# Fall back to traditional runtime evaluation
99101
perf_gain = performance_gain(

codeflash/verification/parse_test_output.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def parse_func(file_path: Path) -> XMLParser:
3737

3838

3939
matches_re_start = re.compile(r"!\$######(.*?):(.*?)([^\.:]*?):(.*?):(.*?):(.*?)######\$!\n")
40-
matches_re_end = re.compile(r"!######(.*?):(.*?)([^\.:]*?):(.*?):(.*?):(.*?)(?::throughput_([\d\.]+)_ops_per_sec)?######!")
40+
matches_re_end = re.compile(
41+
r"!######(.*?):(.*?)([^\.:]*?):(.*?):(.*?):(.*?)(?::throughput_([\d\.]+)_ops_per_sec)?######!"
42+
)
4143

4244

4345
def parse_test_return_values_bin(file_location: Path, test_files: TestFiles, test_config: TestConfig) -> TestResults:

0 commit comments

Comments
 (0)