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

pantsbuild / pants / 19250292619

11 Nov 2025 12:09AM UTC coverage: 77.865% (-2.4%) from 80.298%
19250292619

push

github

web-flow
flag non-runnable targets used with `code_quality_tool` (#22875)

2 of 5 new or added lines in 2 files covered. (40.0%)

1487 existing lines in 72 files now uncovered.

71448 of 91759 relevant lines covered (77.86%)

3.22 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
11✔
5
from typing import Any
11✔
6

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

9
import pants._version
11✔
10

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

14

15
# Simple derived class to enable comparison with strings in BUILD files.
16
class Version(_Version):
11✔
17
    def __hash__(self):
11✔
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):
11✔
24
        if isinstance(other, str):
1✔
25
            other = Version(other)
×
26
        return super().__eq__(other)
1✔
27

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

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

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

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

48
    def __ge__(self, other: Any):
11✔
49
        if isinstance(other, str):
11✔
50
            other = Version(other)
×
51
        return super().__ge__(other)
11✔
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"
11✔
57

58

59
VERSION: str = (
11✔
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)
11✔
74

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