From 07211f0200e10aa1ef59a0ec32e8984d49111ff6 Mon Sep 17 00:00:00 2001 From: trocher <43437004+trocher@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:44:30 +0100 Subject: [PATCH] expose detect_version_specifier_set --- tests/test_versioning.py | 6 +++--- vvm/utils/versioning.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_versioning.py b/tests/test_versioning.py index d4d766e..0906530 100644 --- a/tests/test_versioning.py +++ b/tests/test_versioning.py @@ -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 @@ -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) diff --git a/vvm/utils/versioning.py b/vvm/utils/versioning.py index 7f931fb..ea54be0 100644 --- a/vvm/utils/versioning.py +++ b/vvm/utils/versioning.py @@ -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 ------- @@ -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)