Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codeflash/cli_cmds/cli_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
21 changes: 11 additions & 10 deletions codeflash/cli_cmds/cmd_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}"
Expand Down Expand Up @@ -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():
Expand All @@ -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

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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),
)

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion codeflash/code_utils/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
2 changes: 1 addition & 1 deletion codeflash/discovery/functions_to_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion codeflash/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading