Raise a `ValueError` instead of asserting
@@ -252,10 +252,13 @@ class RustLanguage(Language):
def _cargo_metadata(cwd: pathlib.Path) -> Dict[str, Any]:
"""Runs `cargo metadata` for a Cargo.toml file in `cwd` or its parent directories.
+
+ :raises ValueError: if `cwd` is not absolute
"""
def find_root_manifest_for_wd() -> pathlib.Path:
# https://docs.rs/cargo/0.48.0/cargo/util/important_paths/fn.find_root_manifest_for_wd.html
- assert cwd.is_absolute()
+ if not cwd.is_absolute():
+ raise ValueError(f'the `cwd` parameter must be absolute: {cwd}')
for directory in [cwd, *cwd.parents]:
manifest_path = directory / 'Cargo.toml'
if manifest_path.exists():
