Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a hint with the correct version specifier #25

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tests/test_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def test_version_does_not_exist():

def test_npm_version_for_04_release():
with pytest.raises(UnexpectedVersionError) as excinfo:
detect_vyper_version_from_source("# pragma version ^0.4.0")
detect_vyper_version_from_source("# pragma version ^0.4.1")

expected_msg = "Please use the pypi-style version specifier for vyper versions >= 0.4.0"
assert str(excinfo.value) == expected_msg
assert str(excinfo.value) == (
"Please use the pypi-style version specifier for vyper versions >= 0.4.0 (hint: ~=0.4.1)"
)
6 changes: 4 additions & 2 deletions vvm/utils/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,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)
raise UnexpectedVersionError(
f"Please use the pypi-style version specifier "
f"for vyper versions >= 0.4.0 (hint: ~={version_str})"
DanielSchiavini marked this conversation as resolved.
Show resolved Hide resolved
)
# for v0.x, both specifiers are equivalent
specifier = "~=" # finds compatible versions

Expand Down
Loading