Skip to content

Commit

Permalink
expose detect_version_specifier_set
Browse files Browse the repository at this point in the history
  • Loading branch information
trocher committed Nov 19, 2024
1 parent 6906b1a commit 07211f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions tests/test_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from vvm import detect_vyper_version_from_source
from vvm.exceptions import UnexpectedVersionError
from vvm.utils.versioning import _detect_version_specifier, _pick_vyper_version
from vvm.utils.versioning import detect_version_specifier_set, _pick_vyper_version


def test_foo_vyper_version(foo_source, vyper_version):
specifier = _detect_version_specifier(foo_source)
specifier = detect_version_specifier_set(foo_source)
assert str(specifier) == f"=={vyper_version}"
assert vyper_version.major == 0
assert _pick_vyper_version(specifier) == vyper_version
Expand Down Expand Up @@ -37,7 +37,7 @@ def test_vyper_version(
def foo() -> int128:
return 42
"""
detected = _detect_version_specifier(source)
detected = detect_version_specifier_set(source)
assert detected == SpecifierSet(expected_specifier_set)
if expected_version == "latest":
expected_version = str(latest_version)
Expand Down
8 changes: 4 additions & 4 deletions vvm/utils/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
_VERSION_RE = re.compile(r"^(?:#\s*(?:@version|pragma\s+version)\s+(.*))", re.MULTILINE)


def _detect_version_specifier(source_code: str) -> Optional[SpecifierSet]:
def detect_version_specifier_set(source_code: str) -> Optional[SpecifierSet]:
"""
Detect the version given by the pragma version in the source code.
Detect the specifier set given by the pragma version in the source code.
Arguments
---------
source_code : str
Source code to detect the version from.
Source code to detect the specifier set from.
Returns
-------
Expand Down Expand Up @@ -98,7 +98,7 @@ def detect_vyper_version_from_source(source_code: str, **kwargs: Any) -> Optiona
Optional[Version]
vyper version, or None if no version could be detected.
"""
specifier_set = _detect_version_specifier(source_code)
specifier_set = detect_version_specifier_set(source_code)
if specifier_set is None:
return None
return _pick_vyper_version(specifier_set, **kwargs)

0 comments on commit 07211f0

Please sign in to comment.