@@ -155,20 +155,30 @@ def ask_run_end_to_end_test(args: Namespace) -> None:
155155 run_end_to_end_test (args , bubble_sort_path , bubble_sort_test_path )
156156
157157
158- def is_valid_pyproject_toml (pyproject_toml_path : Path ) -> dict [str , Any ] | None :
158+ def is_valid_pyproject_toml (pyproject_toml_path : Path ) -> tuple [ dict [str , Any ] | None , str ]: # noqa: PLR0911
159159 if not pyproject_toml_path .exists ():
160- return None
160+ return None , f"Configuration file not found: { pyproject_toml_path } "
161+
161162 try :
162163 config , _ = parse_config_file (pyproject_toml_path )
163- except Exception :
164- return None
164+ except Exception as e :
165+ return None , f"Failed to parse configuration: { e } "
166+
167+ module_root = config .get ("module_root" )
168+ if not module_root :
169+ return None , "Missing required field: 'module_root'"
170+
171+ if not Path (module_root ).is_dir ():
172+ return None , f"Invalid 'module_root': directory does not exist at { module_root } "
173+
174+ tests_root = config .get ("tests_root" )
175+ if not tests_root :
176+ return None , "Missing required field: 'tests_root'"
165177
166- if "module_root" not in config or config ["module_root" ] is None or not Path (config ["module_root" ]).is_dir ():
167- return None
168- if "tests_root" not in config or config ["tests_root" ] is None or not Path (config ["tests_root" ]).is_dir ():
169- return None
178+ if not Path (tests_root ).is_dir ():
179+ return None , f"Invalid 'tests_root': directory does not exist at { tests_root } "
170180
171- return config
181+ return config , ""
172182
173183
174184def should_modify_pyproject_toml () -> tuple [bool , dict [str , Any ] | None ]:
@@ -180,7 +190,7 @@ def should_modify_pyproject_toml() -> tuple[bool, dict[str, Any] | None]:
180190
181191 pyproject_toml_path = Path .cwd () / "pyproject.toml"
182192
183- config = is_valid_pyproject_toml (pyproject_toml_path )
193+ config , _message = is_valid_pyproject_toml (pyproject_toml_path )
184194 if config is None :
185195 return True , None
186196
@@ -631,7 +641,7 @@ def check_for_toml_or_setup_file() -> str | None:
631641
632642def install_github_actions (override_formatter_check : bool = False ) -> None : # noqa: FBT001, FBT002
633643 try :
634- config , config_file_path = parse_config_file (override_formatter_check = override_formatter_check )
644+ config , _config_file_path = parse_config_file (override_formatter_check = override_formatter_check )
635645
636646 ph ("cli-github-actions-install-started" )
637647 try :
0 commit comments