• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 20333307239

18 Dec 2025 10:07AM UTC coverage: 75.452% (-4.8%) from 80.295%
20333307239

Pull #22949

github

web-flow
Merge b07232683 into 407284c67
Pull Request #22949: Add experimental uv resolver for Python lockfiles

51 of 96 new or added lines in 5 files covered. (53.13%)

2857 existing lines in 120 files now uncovered.

66315 of 87890 relevant lines covered (75.45%)

2.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.22
/src/python/pants/version.py
1
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
import os
9✔
5
from typing import Any
9✔
6

7
from packaging.version import Version as _Version
9✔
8

9
import pants._version
9✔
10

11
# Generate an inferable dependency on the `pants._version` package and its associated resources.
12
from pants.util.resources import read_resource
9✔
13

14

15
# Simple derived class to enable comparison with strings in BUILD files.
16
class Version(_Version):
9✔
17
    def __hash__(self):
9✔
18
        # This is required to be directly implemented because we implement __eq__,
19
        # see the docs for object.__hash__:
20
        # https://docs.python.org/3/reference/datamodel.html#object.__hash__
21
        return super().__hash__()
4✔
22

23
    def __eq__(self, other: Any):
9✔
24
        if isinstance(other, str):
1✔
25
            other = Version(other)
×
26
        return super().__eq__(other)
1✔
27

28
    def __ne__(self, other: Any):
9✔
29
        if isinstance(other, str):
1✔
30
            other = Version(other)
×
31
        return super().__ne__(other)
1✔
32

33
    def __lt__(self, other: Any):
9✔
UNCOV
34
        if isinstance(other, str):
×
35
            other = Version(other)
×
UNCOV
36
        return super().__lt__(other)
×
37

38
    def __le__(self, other: Any):
9✔
39
        if isinstance(other, str):
9✔
40
            other = Version(other)
×
41
        return super().__le__(other)
9✔
42

43
    def __gt__(self, other: Any):
9✔
44
        if isinstance(other, str):
×
45
            other = Version(other)
×
46
        return super().__gt__(other)
×
47

48
    def __ge__(self, other: Any):
9✔
49
        if isinstance(other, str):
9✔
50
            other = Version(other)
×
51
        return super().__ge__(other)
9✔
52

53

54
# Set this env var to override the version pants reports. Useful for testing.
55
# Do not change. (see below)
56
_PANTS_VERSION_OVERRIDE = "_PANTS_VERSION_OVERRIDE"
9✔
57

58

59
VERSION: str = (
9✔
60
    # Do not remove/change this env var without coordinating with `pantsbuild/scie-pants` as it is
61
    # being used when bootstrapping Pants with a released version.
62
    os.environ.get(_PANTS_VERSION_OVERRIDE)
63
    or
64
    # NB: We expect VERSION to always have an entry and want a runtime failure if this is false.
65
    # NB: Since "pants" is the namespace for multiple packages, we need to put VERSION underneath
66
    # the tree that only the `pantsbuild.pants` package owns. Hence `pants._version`.
67
    # Furthermore, we can't outright move the file there from its previous home of pants/VERSION, as
68
    # (as of the time of writing) the Pants shim expects it at pants/VERSION. So we symlink the new
69
    # home to the old home, knowing that Pants is symlink oblivious when collecting sources.
70
    read_resource(pants._version.__name__, "VERSION").decode().strip()
71
)
72

73
PANTS_SEMVER = Version(VERSION)
9✔
74

75
# E.g. 2.0 or 2.2.
76
MAJOR_MINOR = f"{PANTS_SEMVER.major}.{PANTS_SEMVER.minor}"
9✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc