Skip to content

Commit b18d2c9

Browse files
better name
1 parent 28f50cc commit b18d2c9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

codeflash/code_utils/code_replacer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def replace_function_definitions_in_module(
412412
module_abspath: Path,
413413
preexisting_objects: set[tuple[str, tuple[FunctionParent, ...]]],
414414
project_root_path: Path,
415-
global_assignments_added_before: bool = False, # noqa: FBT001, FBT002
415+
should_add_global_assignments: bool = True, # noqa: FBT001, FBT002
416416
) -> bool:
417417
source_code: str = module_abspath.read_text(encoding="utf8")
418418
code_to_apply = get_optimized_code_for_module(module_abspath.relative_to(project_root_path), optimized_code)
@@ -422,7 +422,7 @@ def replace_function_definitions_in_module(
422422
# becuase of an "edge case" where the optimized code intoduced a new import and a global assignment using that import
423423
# and that import wasn't used before, so it was ignored when calling AddImportsVisitor.add_needed_import inside replace_functions_and_add_imports (because the global assignment wasn't added yet)
424424
# this was added at https://github.com/codeflash-ai/codeflash/pull/448
425-
add_global_assignments(code_to_apply, source_code) if not global_assignments_added_before else source_code,
425+
add_global_assignments(code_to_apply, source_code) if should_add_global_assignments else source_code,
426426
function_names,
427427
code_to_apply,
428428
module_abspath,

codeflash/context/unused_definition_remover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def revert_unused_helper_functions(
537537
module_abspath=file_path,
538538
preexisting_objects=set(), # Empty set since we're reverting
539539
project_root_path=project_root,
540-
global_assignments_added_before=True, # since we revert helpers functions after applying the optimization, we know that the file already has global assignments added, otherwise they would be added twice.
540+
should_add_global_assignments=False, # since we revert helpers functions after applying the optimization, we know that the file already has global assignments added, otherwise they would be added twice.
541541
)
542542

543543
if reverted_code:

0 commit comments

Comments
 (0)