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

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

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

47.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
1✔
5
from typing import Any
1✔
6

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

9
import pants._version
1✔
10

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

14

15
# Simple derived class to enable comparison with strings in BUILD files.
16
class Version(_Version):
1✔
17
    def __hash__(self):
1✔
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__
UNCOV
21
        return super().__hash__()
×
22

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

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

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

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

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

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

58

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

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