From ae4b3326412de4505a5383b371d6e5366654b29e Mon Sep 17 00:00:00 2001 From: Steve Brown Date: Wed, 24 Jun 2026 17:16:53 +0100 Subject: [PATCH 1/2] SG-43838 Add uncovered function to validate Codecov threshold config This function is intentionally not covered by tests. It exists solely to verify that the codecov.yml changes in the parent branch cause Codecov to report the miss as advisory-only rather than failing CI. Co-Authored-By: Claude Sonnet 4.6 --- python/tank/util/version.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/python/tank/util/version.py b/python/tank/util/version.py index 158cdece7..31e65341f 100644 --- a/python/tank/util/version.py +++ b/python/tank/util/version.py @@ -183,6 +183,27 @@ def normalize_version_format(version: str) -> str: return version +def format_version_range(min_version, max_version=None): + """ + Format a version range as a human-readable string. + + :param str min_version: The minimum version of the range. + :param str max_version: The maximum version of the range, or None for open-ended. + :returns: A formatted string such as ">=1.2.3" or ">=1.2.3, <2.0.0". + :rtype: str + """ + if max_version is None: + return ">=%s" % min_version + + if is_version_newer_or_equal(min_version, max_version): + raise ValueError( + "min_version (%s) must be less than max_version (%s)" + % (min_version, max_version) + ) + + return ">=%s, <%s" % (min_version, max_version) + + def _compare_versions(a, b): """ Tests if version a is newer than version b. From dc1f3cf2dee4b822d0b4ed43cdd30187c248c6f9 Mon Sep 17 00:00:00 2001 From: Steve Brown Date: Thu, 25 Jun 2026 14:32:38 +0100 Subject: [PATCH 2/2] SG-43838 Engineer ~85% patch coverage to validate threshold config Adds str() coercion to format_version_range (7 executable lines) and tests for the open-ended and bounded-range paths, leaving only the ValueError branch uncovered. Expected patch coverage: 6/7 = 85.7%. Co-Authored-By: Claude Sonnet 4.6 --- python/tank/util/version.py | 2 ++ tests/util_tests/test_format_version_range.py | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/util_tests/test_format_version_range.py diff --git a/python/tank/util/version.py b/python/tank/util/version.py index 31e65341f..e21c88ac3 100644 --- a/python/tank/util/version.py +++ b/python/tank/util/version.py @@ -192,6 +192,8 @@ def format_version_range(min_version, max_version=None): :returns: A formatted string such as ">=1.2.3" or ">=1.2.3, <2.0.0". :rtype: str """ + min_version = str(min_version) + if max_version is None: return ">=%s" % min_version diff --git a/tests/util_tests/test_format_version_range.py b/tests/util_tests/test_format_version_range.py new file mode 100644 index 000000000..145415efd --- /dev/null +++ b/tests/util_tests/test_format_version_range.py @@ -0,0 +1,24 @@ +# Copyright (c) 2024 Shotgun Software Inc. +# +# CONFIDENTIAL AND PROPRIETARY +# +# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit +# Source Code License included in this distribution package. See LICENSE. +# By accessing, using, copying or modifying this work you indicate your +# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights +# not expressly granted therein are reserved by Shotgun Software Inc. + +from tank_test.tank_test_base import setUpModule # noqa +from tank_test.tank_test_base import ShotgunTestBase +from tank.util.version import format_version_range + + +class TestFormatVersionRange(ShotgunTestBase): + def setUp(self): + super().setUp() + + def test_open_ended_range(self): + self.assertEqual(format_version_range("1.2.3"), ">=1.2.3") + + def test_bounded_range(self): + self.assertEqual(format_version_range("1.2.3", "2.0.0"), ">=1.2.3, <2.0.0")