diff --git a/codeflash/cli_cmds/cli_common.py b/codeflash/cli_cmds/cli_common.py index 942b8f634..b8f04ec6e 100644 --- a/codeflash/cli_cmds/cli_common.py +++ b/codeflash/cli_cmds/cli_common.py @@ -74,7 +74,7 @@ def inquirer_wrapper_path(*args: str, **kwargs: str) -> dict[str, str] | None: new_kwargs["message"] = last_message new_args.append(args[0]) - return cast(dict[str, str], inquirer.prompt([inquirer.Path(*new_args, **new_kwargs)])) + return cast("dict[str, str]", inquirer.prompt([inquirer.Path(*new_args, **new_kwargs)])) def split_string_to_fit_width(string: str, width: int) -> list[str]: diff --git a/codeflash/cli_cmds/cmd_init.py b/codeflash/cli_cmds/cmd_init.py index 5df70828c..0cacddd44 100644 --- a/codeflash/cli_cmds/cmd_init.py +++ b/codeflash/cli_cmds/cmd_init.py @@ -68,7 +68,6 @@ def init_codeflash() -> None: did_add_new_key = prompt_api_key() if should_modify_pyproject_toml(): - setup_info: SetupInfo = collect_setup_info() configure_pyproject_toml(setup_info) @@ -81,7 +80,6 @@ def init_codeflash() -> None: if "setup_info" in locals(): module_string = f" you selected ({setup_info.module_root})" - click.echo( f"{LF}" f"⚡️ Codeflash is now set up! You can now run:{LF}" @@ -123,18 +121,19 @@ def ask_run_end_to_end_test(args: Namespace) -> None: bubble_sort_path, bubble_sort_test_path = create_bubble_sort_file_and_test(args) run_end_to_end_test(args, bubble_sort_path, bubble_sort_test_path) + def should_modify_pyproject_toml() -> bool: - """ - Check if the current directory contains a valid pyproject.toml file with codeflash config + """Check if the current directory contains a valid pyproject.toml file with codeflash config If it does, ask the user if they want to re-configure it. """ from rich.prompt import Confirm + pyproject_toml_path = Path.cwd() / "pyproject.toml" if not pyproject_toml_path.exists(): return True try: config, config_file_path = parse_config_file(pyproject_toml_path) - except Exception as e: + except Exception: return True if "module_root" not in config or config["module_root"] is None or not Path(config["module_root"]).is_dir(): @@ -143,7 +142,9 @@ def should_modify_pyproject_toml() -> bool: return True create_toml = Confirm.ask( - f"✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?", default=False, show_default=True + "✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?", + default=False, + show_default=True, ) return create_toml @@ -224,7 +225,7 @@ def collect_setup_info() -> SetupInfo: else: apologize_and_exit() else: - tests_root = Path(curdir) / Path(cast(str, tests_root_answer)) + tests_root = Path(curdir) / Path(cast("str", tests_root_answer)) tests_root = tests_root.relative_to(curdir) ph("cli-tests-root-provided") @@ -278,9 +279,9 @@ def collect_setup_info() -> SetupInfo: return SetupInfo( module_root=str(module_root), tests_root=str(tests_root), - test_framework=cast(str, test_framework), + test_framework=cast("str", test_framework), ignore_paths=ignore_paths, - formatter=cast(str, formatter), + formatter=cast("str", formatter), git_remote=str(git_remote), ) @@ -390,7 +391,7 @@ def check_for_toml_or_setup_file() -> str | None: click.echo("⏩️ Skipping pyproject.toml creation.") apologize_and_exit() click.echo() - return cast(str, project_name) + return cast("str", project_name) def install_github_actions(override_formatter_check: bool = False) -> None: diff --git a/codeflash/code_utils/config_parser.py b/codeflash/code_utils/config_parser.py index d814f12d0..73eafd1dd 100644 --- a/codeflash/code_utils/config_parser.py +++ b/codeflash/code_utils/config_parser.py @@ -87,7 +87,7 @@ def parse_config_file( "In pyproject.toml, Codeflash only supports the 'test-framework' as pytest and unittest." ) if len(config["formatter-cmds"]) > 0: - #see if this is happening during GitHub actions setup + # see if this is happening during GitHub actions setup if not override_formatter_check: assert config["formatter-cmds"][0] != "your-formatter $file", ( "The formatter command is not set correctly in pyproject.toml. Please set the " diff --git a/codeflash/discovery/functions_to_optimize.py b/codeflash/discovery/functions_to_optimize.py index a234a2827..f91977c0f 100644 --- a/codeflash/discovery/functions_to_optimize.py +++ b/codeflash/discovery/functions_to_optimize.py @@ -300,7 +300,7 @@ def get_all_replay_test_functions( if valid_function.qualified_name == function_name ] ) - if len(filtered_list): + if filtered_list: filtered_valid_functions[file_path] = filtered_list return filtered_valid_functions diff --git a/codeflash/models/models.py b/codeflash/models/models.py index a00834cdd..c3dd8b5a5 100644 --- a/codeflash/models/models.py +++ b/codeflash/models/models.py @@ -529,7 +529,7 @@ def __eq__(self, other: object) -> bool: if len(self) != len(other): return False original_recursion_limit = sys.getrecursionlimit() - cast(TestResults, other) + cast("TestResults", other) for test_result in self: other_test_result = other.get_by_unique_invocation_loop_id(test_result.unique_invocation_loop_id) if other_test_result is None: