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

pantsbuild / pants / 24145945949

08 Apr 2026 04:14PM UTC coverage: 82.077% (-10.8%) from 92.91%
24145945949

Pull #23233

github

web-flow
Merge 089d98e3c into 9036734c9
Pull Request #23233: Introduce a LockfileFormat enum.

8 of 11 new or added lines in 4 files covered. (72.73%)

7635 existing lines in 306 files now uncovered.

63732 of 77649 relevant lines covered (82.08%)

2.96 hits per line

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

77.78
/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
7✔
5
from typing import Any
7✔
6

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

9
# pants: infer-dep(/src/python/pants/_version/__init__.py)
10
# pants: infer-dep(/src/python/pants/_version/VERSION)
11
import pants._version
7✔
12

13
# Generate an OG inferable dependency on the `pants._version` package and its associated resources.
14
from pants.util.resources import read_resource
7✔
15

16

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

25
    def __eq__(self, other: Any):
7✔
26
        if isinstance(other, str):
3✔
UNCOV
27
            other = Version(other)
×
28
        return super().__eq__(other)
3✔
29

30
    def __ne__(self, other: Any):
7✔
31
        if isinstance(other, str):
1✔
UNCOV
32
            other = Version(other)
×
33
        return super().__ne__(other)
1✔
34

35
    def __lt__(self, other: Any):
7✔
36
        if isinstance(other, str):
2✔
UNCOV
37
            other = Version(other)
×
38
        return super().__lt__(other)
2✔
39

40
    def __le__(self, other: Any):
7✔
41
        if isinstance(other, str):
7✔
UNCOV
42
            other = Version(other)
×
43
        return super().__le__(other)
7✔
44

45
    def __gt__(self, other: Any):
7✔
UNCOV
46
        if isinstance(other, str):
×
UNCOV
47
            other = Version(other)
×
UNCOV
48
        return super().__gt__(other)
×
49

50
    def __ge__(self, other: Any):
7✔
51
        if isinstance(other, str):
7✔
UNCOV
52
            other = Version(other)
×
53
        return super().__ge__(other)
7✔
54

55

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

60

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

75
PANTS_SEMVER = Version(VERSION)
7✔
76

77
# E.g. 2.0 or 2.2.
78
MAJOR_MINOR = f"{PANTS_SEMVER.major}.{PANTS_SEMVER.minor}"
7✔
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

© 2026 Coveralls, Inc