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

pantsbuild / pants / 24055979590

06 Apr 2026 11:17PM UTC coverage: 52.37% (-40.5%) from 92.908%
24055979590

Pull #23225

github

web-flow
Merge 67474653c into 542ca048d
Pull Request #23225: Add --test-show-all-batch-targets to expose all targets in batched pytest

6 of 17 new or added lines in 2 files covered. (35.29%)

23030 existing lines in 605 files now uncovered.

31643 of 60422 relevant lines covered (52.37%)

1.05 hits per line

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

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

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

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

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

16

17
# Simple derived class to enable comparison with strings in BUILD files.
18
class Version(_Version):
2✔
19
    def __hash__(self):
2✔
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__
UNCOV
23
        return super().__hash__()
×
24

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

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

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

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

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

50
    def __ge__(self, other: Any):
2✔
51
        if isinstance(other, str):
2✔
UNCOV
52
            other = Version(other)
×
53
        return super().__ge__(other)
2✔
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"
2✔
59

60

61
VERSION: str = (
2✔
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)
2✔
76

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