Skip to content

Commit b8bbcd0

Browse files
authored
Merge branch 'main' into format-genfile-fix
2 parents fc9ba8c + b17c5bf commit b8bbcd0

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,23 @@ def ask_run_end_to_end_test(args: Namespace) -> None:
171171
run_end_to_end_test(args, file_path)
172172

173173

174-
def is_valid_pyproject_toml(pyproject_toml_path: Path) -> tuple[bool, dict[str, Any] | None, str]: # noqa: PLR0911
174+
def config_found(pyproject_toml_path: Union[str, Path]) -> tuple[bool, str]:
175+
pyproject_toml_path = Path(pyproject_toml_path)
176+
175177
if not pyproject_toml_path.exists():
176-
return False, None, f"Configuration file not found: {pyproject_toml_path}"
178+
return False, f"Configuration file not found: {pyproject_toml_path}"
179+
180+
if not pyproject_toml_path.is_file():
181+
return False, f"Configuration file is not a file: {pyproject_toml_path}"
182+
183+
if pyproject_toml_path.suffix != ".toml":
184+
return False, f"Configuration file is not a .toml file: {pyproject_toml_path}"
185+
186+
return True, ""
177187

188+
189+
def is_valid_pyproject_toml(pyproject_toml_path: Union[str, Path]) -> tuple[bool, dict[str, Any] | None, str]:
190+
pyproject_toml_path = Path(pyproject_toml_path)
178191
try:
179192
config, _ = parse_config_file(pyproject_toml_path)
180193
except Exception as e:
@@ -206,6 +219,10 @@ def should_modify_pyproject_toml() -> tuple[bool, dict[str, Any] | None]:
206219

207220
pyproject_toml_path = Path.cwd() / "pyproject.toml"
208221

222+
found, _ = config_found(pyproject_toml_path)
223+
if not found:
224+
return True, None
225+
209226
valid, config, _message = is_valid_pyproject_toml(pyproject_toml_path)
210227
if not valid:
211228
# needs to be re-configured

codeflash/lsp/beta.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from codeflash.cli_cmds.cmd_init import (
1515
CommonSections,
1616
VsCodeSetupInfo,
17+
config_found,
1718
configure_pyproject_toml,
1819
create_empty_pyproject_toml,
1920
create_find_common_tags_file,
@@ -263,6 +264,10 @@ def init_project(params: ValidateProjectParams) -> dict[str, str]:
263264
"root": root,
264265
}
265266

267+
found, message = config_found(pyproject_toml_path)
268+
if not found:
269+
return {"status": "error", "message": message}
270+
266271
valid, config, reason = is_valid_pyproject_toml(pyproject_toml_path)
267272
if not valid:
268273
return {

codeflash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# These version placeholders will be replaced by uv-dynamic-versioning during build.
2-
__version__ = "0.18.3"
2+
__version__ = "0.18.4"

0 commit comments

Comments
 (0)