From 9edbf27a4d2afa7b47df9411ff18b2c7bc08b7fe Mon Sep 17 00:00:00 2001 From: ali Date: Mon, 17 Nov 2025 17:58:42 +0200 Subject: [PATCH] move the config default values to the client --- codeflash/lsp/beta.py | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/codeflash/lsp/beta.py b/codeflash/lsp/beta.py index 236828be7..c4e305faa 100644 --- a/codeflash/lsp/beta.py +++ b/codeflash/lsp/beta.py @@ -235,37 +235,11 @@ def get_config_suggestions(_params: any) -> dict[str, any]: tests_root_suggestions.append(".") default_tests_root = tests_root_suggestions[0] if tests_root_suggestions else "." - try: - configured_module_root = ( - Path(server.args.module_root).relative_to(Path.cwd()) if server.args.module_root else None - ) - except: # noqa : E722 - configured_module_root = None - try: - configured_tests_root = Path(server.args.tests_root).relative_to(Path.cwd()) if server.args.tests_root else None - except: # noqa : E722 - configured_tests_root = None - try: - configured_test_framework = server.args.test_framework if server.args.test_framework else None - except: # noqa : E722 - configured_test_framework = None - configured_formatter = "" - try: - if isinstance(server.args.formatter_cmds, list): - configured_formatter = " && ".join([cmd.strip() for cmd in server.args.formatter_cmds]) - elif isinstance(server.args.formatter_cmds, str): - configured_formatter = server.args.formatter_cmds.strip() - except: # noqa : E722 - configured_formatter = "disabled" - return { - "module_root": {"choices": module_root_suggestions, "default": configured_module_root or default_module_root}, - "tests_root": {"choices": tests_root_suggestions, "default": configured_tests_root or default_tests_root}, - "test_framework": { - "choices": test_framework_suggestions, - "default": configured_test_framework or default_test_framework, - }, - "formatter_cmds": {"choices": formatter_suggestions, "default": configured_formatter or default_formatter}, + "module_root": {"choices": module_root_suggestions, "default": default_module_root}, + "tests_root": {"choices": tests_root_suggestions, "default": default_tests_root}, + "test_framework": {"choices": test_framework_suggestions, "default": default_test_framework}, + "formatter_cmds": {"choices": formatter_suggestions, "default": default_formatter}, } @@ -319,7 +293,13 @@ def init_project(params: ValidateProjectParams) -> dict[str, str]: } args = process_args() - return {"status": "success", "moduleRoot": args.module_root, "pyprojectPath": pyproject_toml_path, "root": root} + return { + "status": "success", + "moduleRoot": args.module_root, + "pyprojectPath": pyproject_toml_path, + "root": root, + "existingConfig": config, + } def _initialize_optimizer_if_api_key_is_valid(api_key: Optional[str] = None) -> dict[str, str]: