Skip to content

Commit

Permalink
Reject npm specifier for >=0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Sep 17, 2024
1 parent b3e2895 commit 0d3522c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,12 @@ def test_version_does_not_exist():
with pytest.raises(UnexpectedVersionError) as excinfo:
detect_vyper_version_from_source("# pragma version 2024.0.1")
assert str(excinfo.value) == "No installable Vyper satisfies the specifier ==2024.0.1"


def test_npm_version_for_04_release():
with pytest.raises(UnexpectedVersionError) as excinfo:
detect_vyper_version_from_source("# pragma version ^0.4.0")
assert (
str(excinfo.value)
== "Please use the pypi-style version specifier for vyper versions >= 0.4.0"
)
4 changes: 4 additions & 0 deletions vvm/utils/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def _detect_version_specifier(source_code: str) -> Specifier:

specifier, version_str = match.groups()
if specifier in ("~", "^"): # convert from npm-style to pypi-style
if Version(version_str) >= Version("0.4.0"):
error = "Please use the pypi-style version specifier for vyper versions >= 0.4.0"
raise UnexpectedVersionError(error)

if specifier == "^" and not version_str.startswith("0."):
# Minor match, remove the patch from the version
# Note: not for 0.x versions, they should only match minor versions
Expand Down

0 comments on commit 0d3522c

Please sign in to comment.