better validation for the config file path
Some checks are pending
CodeFlash / Optimize new Python code (pull_request) Waiting to run
E2E - Async / async-optimization (pull_request) Waiting to run
E2E - Bubble Sort Benchmark / benchmark-bubble-sort-optimization (pull_request) Waiting to run
E2E - Bubble Sort Pytest (No Git) / bubble-sort-optimization-pytest-no-git (pull_request) Waiting to run
E2E - Bubble Sort Unittest / bubble-sort-optimization-unittest (pull_request) Waiting to run
/ Run pr agent on every pull request, respond to user comments (pull_request) Waiting to run
Lint / Run pre-commit hooks (pull_request) Waiting to run
Coverage E2E / end-to-end-test-coverage (pull_request) Waiting to run
E2E - Futurehouse Structure / futurehouse-structure (pull_request) Waiting to run
E2E - Init Optimization / init-optimization (pull_request) Waiting to run
E2E - Topological Sort (Worktree) / topological-sort-worktree-optimization (pull_request) Waiting to run
E2E - Tracer Replay / tracer-replay (pull_request) Waiting to run
PR Labeler / label-workflow-changes (pull_request) Waiting to run
Mypy Type Checking for CLI / type-check-cli (pull_request) Waiting to run
unit-tests / unit-tests (3.10) (pull_request) Waiting to run
unit-tests / unit-tests (3.11) (pull_request) Waiting to run
unit-tests / unit-tests (3.12) (pull_request) Waiting to run
unit-tests / unit-tests (3.13) (pull_request) Waiting to run
unit-tests / unit-tests (3.14) (pull_request) Waiting to run
unit-tests / unit-tests (3.9) (pull_request) Waiting to run
windows-unit-tests / windows-unit-tests (pull_request) Waiting to run
Some checks are pending
CodeFlash / Optimize new Python code (pull_request) Waiting to run
E2E - Async / async-optimization (pull_request) Waiting to run
E2E - Bubble Sort Benchmark / benchmark-bubble-sort-optimization (pull_request) Waiting to run
E2E - Bubble Sort Pytest (No Git) / bubble-sort-optimization-pytest-no-git (pull_request) Waiting to run
E2E - Bubble Sort Unittest / bubble-sort-optimization-unittest (pull_request) Waiting to run
/ Run pr agent on every pull request, respond to user comments (pull_request) Waiting to run
Lint / Run pre-commit hooks (pull_request) Waiting to run
Coverage E2E / end-to-end-test-coverage (pull_request) Waiting to run
E2E - Futurehouse Structure / futurehouse-structure (pull_request) Waiting to run
E2E - Init Optimization / init-optimization (pull_request) Waiting to run
E2E - Topological Sort (Worktree) / topological-sort-worktree-optimization (pull_request) Waiting to run
E2E - Tracer Replay / tracer-replay (pull_request) Waiting to run
PR Labeler / label-workflow-changes (pull_request) Waiting to run
Mypy Type Checking for CLI / type-check-cli (pull_request) Waiting to run
unit-tests / unit-tests (3.10) (pull_request) Waiting to run
unit-tests / unit-tests (3.11) (pull_request) Waiting to run
unit-tests / unit-tests (3.12) (pull_request) Waiting to run
unit-tests / unit-tests (3.13) (pull_request) Waiting to run
unit-tests / unit-tests (3.14) (pull_request) Waiting to run
unit-tests / unit-tests (3.9) (pull_request) Waiting to run
windows-unit-tests / windows-unit-tests (pull_request) Waiting to run
This commit is contained in:
parent
daa7627a5c
commit
ea9a2db1f4
2 changed files with 25 additions and 3 deletions
|
|
@ -171,10 +171,23 @@ def ask_run_end_to_end_test(args: Namespace) -> None:
|
|||
run_end_to_end_test(args, file_path)
|
||||
|
||||
|
||||
def is_valid_pyproject_toml(pyproject_toml_path: Path) -> tuple[bool, dict[str, Any] | None, str]: # noqa: PLR0911
|
||||
if not pyproject_toml_path.exists():
|
||||
return False, None, f"Configuration file not found: {pyproject_toml_path}"
|
||||
def config_found(pyproject_toml_path: Union[str, Path]) -> tuple[bool, str]:
|
||||
pyproject_toml_path = Path(pyproject_toml_path)
|
||||
|
||||
if not pyproject_toml_path.exists():
|
||||
return False, f"Configuration file not found: {pyproject_toml_path}"
|
||||
|
||||
if not pyproject_toml_path.is_file():
|
||||
return False, f"Configuration file is not a file: {pyproject_toml_path}"
|
||||
|
||||
if pyproject_toml_path.suffix != ".toml":
|
||||
return False, f"Configuration file is not a .toml file: {pyproject_toml_path}"
|
||||
|
||||
return True, ""
|
||||
|
||||
|
||||
def is_valid_pyproject_toml(pyproject_toml_path: Union[str, Path]) -> tuple[bool, dict[str, Any] | None, str]:
|
||||
pyproject_toml_path = Path(pyproject_toml_path)
|
||||
try:
|
||||
config, _ = parse_config_file(pyproject_toml_path)
|
||||
except Exception as e:
|
||||
|
|
@ -206,6 +219,10 @@ def should_modify_pyproject_toml() -> tuple[bool, dict[str, Any] | None]:
|
|||
|
||||
pyproject_toml_path = Path.cwd() / "pyproject.toml"
|
||||
|
||||
found, _ = config_found(pyproject_toml_path)
|
||||
if not found:
|
||||
return True, None
|
||||
|
||||
valid, config, _message = is_valid_pyproject_toml(pyproject_toml_path)
|
||||
if not valid:
|
||||
# needs to be re-configured
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from codeflash.cli_cmds.cli import process_pyproject_config
|
|||
from codeflash.cli_cmds.cmd_init import (
|
||||
CommonSections,
|
||||
VsCodeSetupInfo,
|
||||
config_found,
|
||||
configure_pyproject_toml,
|
||||
create_empty_pyproject_toml,
|
||||
create_find_common_tags_file,
|
||||
|
|
@ -263,6 +264,10 @@ def init_project(params: ValidateProjectParams) -> dict[str, str]:
|
|||
"root": root,
|
||||
}
|
||||
|
||||
found, message = config_found(pyproject_toml_path)
|
||||
if not found:
|
||||
return {"status": "error", "message": message}
|
||||
|
||||
valid, config, reason = is_valid_pyproject_toml(pyproject_toml_path)
|
||||
if not valid:
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue