Skip to content

Commit

Permalink
fix the error type
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Dec 31, 2024
1 parent 377974a commit f4de511
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pdm/models/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def _parse_url(self) -> None:
if relpath is None:
try:
self.path = Path(url_to_path(url))
except AssertionError:
except ValueError:
pass
else:
self.path = Path(relpath)
Expand Down
3 changes: 2 additions & 1 deletion src/pdm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ def url_to_path(url: str) -> str:

WINDOWS = sys.platform == "win32"

assert url.startswith("file:"), f"You can only turn file: urls into filenames (not {url!r})"
if not url.startswith("file:"):
raise ValueError(f"You can only turn file: urls into filenames (not {url!r})")

_, netloc, path, _, _ = parse.urlsplit(url)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_add_ssh_scheme_to_git_uri(given, expected):

class TestUrlToPath:
def test_non_file_url(self):
with pytest.raises(AssertionError):
with pytest.raises(ValueError):
utils.url_to_path("not_a_file_scheme://netloc/path")

@pytest.mark.skipif(sys.platform.startswith("win"), reason="Non-Windows test")
Expand Down

0 comments on commit f4de511

Please sign in to comment.