Skip to content

Commit b48e9e6

Browse files
pass helper functions source code to the formatter for diff checking
1 parent c24fc90 commit b48e9e6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

codeflash/optimization/function_optimizer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,12 @@ def reformat_code_and_helpers(
605605
new_code = sort_imports(new_code)
606606

607607
new_helper_code: dict[Path, str] = {}
608-
helper_functions_paths = {hf.file_path for hf in helper_functions}
609-
for module_abspath in helper_functions_paths:
610-
formatted_helper_code = format_code(self.args.formatter_cmds, module_abspath)
608+
for hp in helper_functions:
609+
module_abspath = hp.file_path
610+
hp_source_code = hp.source_code
611+
formatted_helper_code = format_code(
612+
self.args.formatter_cmds, module_abspath, optimized_function=hp_source_code
613+
)
611614
if should_sort_imports:
612615
formatted_helper_code = sort_imports(formatted_helper_code)
613616
new_helper_code[module_abspath] = formatted_helper_code

0 commit comments

Comments
 (0)