diff --git a/code_to_optimize/bubble_sort_typed.py b/code_to_optimize/bubble_sort_typed.py index d77af06fe..d0b71f2e0 100644 --- a/code_to_optimize/bubble_sort_typed.py +++ b/code_to_optimize/bubble_sort_typed.py @@ -1,4 +1,4 @@ -from __future__ import annotations +from __future__ import annotations from typing import Any, Callable, Iterable, NewType, Optional, Protocol, TypeVar diff --git a/code_to_optimize/find_common_tags.py b/code_to_optimize/find_common_tags.py new file mode 100644 index 000000000..016905bfc --- /dev/null +++ b/code_to_optimize/find_common_tags.py @@ -0,0 +1,11 @@ +from __future__ import annotations + + +def find_common_tags(articles: list[dict[str, list[str]]]) -> set[str]: + if not articles: + return set() + + common_tags = articles[0]["tags"] + for article in articles[1:]: + common_tags = [tag for tag in common_tags if tag in article["tags"]] + return set(common_tags) diff --git a/codeflash/discovery/functions_to_optimize.py b/codeflash/discovery/functions_to_optimize.py index 7b892a2b5..9a5731753 100644 --- a/codeflash/discovery/functions_to_optimize.py +++ b/codeflash/discovery/functions_to_optimize.py @@ -156,26 +156,18 @@ def get_functions_to_optimize( module_root: Path, ) -> tuple[dict[Path, list[FunctionToOptimize]], int]: assert ( - sum( - [ # Ensure only one of the options is provided - bool(optimize_all), - bool(replay_test), - bool(file), - ] - ) - <= 1 + sum([bool(optimize_all), bool(replay_test), bool(file)]) <= 1 ), "Only one of optimize_all, replay_test, or file should be provided" functions: dict[str, list[FunctionToOptimize]] if optimize_all: - logger.info("Finding all functions in the module '%s' ...", optimize_all) + logger.info("Finding all functions in the module '%s'…", optimize_all) functions = get_all_files_and_functions(Path(optimize_all)) elif replay_test is not None: functions = get_all_replay_test_functions( replay_test=replay_test, test_cfg=test_cfg, project_root_path=project_root ) - elif file is not None: - logger.info("Finding all functions in the file '%s' ...", file) + logger.info("Finding all functions in the file '%s'…", file) functions = find_all_functions_in_file(file) if only_get_this_function is not None: split_function = only_get_this_function.split(".") diff --git a/codeflash/optimization/optimizer.py b/codeflash/optimization/optimizer.py index d3577fb20..6f186e824 100644 --- a/codeflash/optimization/optimizer.py +++ b/codeflash/optimization/optimizer.py @@ -449,7 +449,7 @@ class Optimizer: [ "crosshair", "diffbehavior", - "--max_uninteresting_iterations=128", + "--max_uninteresting_iterations=256", function_to_optimize_optimized_worktree_fqn, function_to_optimize_original_worktree_fqn, ], @@ -463,7 +463,7 @@ class Optimizer: "crosshair", "cover", "--example_output_format=pytest", - "--max_uninteresting_iterations=128", + "--max_uninteresting_iterations=256", function_to_optimize_optimized_worktree_fqn, ], capture_output=True,