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

pantsbuild / pants / 21552830208

31 Jan 2026 11:40PM UTC coverage: 80.277% (-0.05%) from 80.324%
21552830208

Pull #23062

github

web-flow
Merge 808a9786c into 2c4dcf9cf
Pull Request #23062: Remove support for Get

18 of 25 new or added lines in 4 files covered. (72.0%)

17119 existing lines in 541 files now uncovered.

78278 of 97510 relevant lines covered (80.28%)

3.36 hits per line

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

77.14
/src/python/pants/backend/plugin_development/pants_requirements.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from pants.backend.python.target_types import (
2✔
5
    PythonRequirementFindLinksField,
6
    PythonRequirementModulesField,
7
    PythonRequirementResolveField,
8
    PythonRequirementsField,
9
    PythonRequirementTarget,
10
)
UNCOV
11
from pants.engine.rules import collect_rules, rule
2✔
UNCOV
12
from pants.engine.target import (
2✔
13
    COMMON_TARGET_FIELDS,
14
    BoolField,
15
    GeneratedTargets,
16
    GenerateTargetsRequest,
17
    StringField,
18
    TargetGenerator,
19
)
UNCOV
20
from pants.engine.unions import UnionMembership, UnionRule
2✔
UNCOV
21
from pants.util.strutil import help_text
2✔
UNCOV
22
from pants.version import PANTS_SEMVER
2✔
23

24

UNCOV
25
class PantsRequirementsTestutilField(BoolField):
2✔
UNCOV
26
    alias = "testutil"
2✔
UNCOV
27
    default = True
2✔
UNCOV
28
    help = "If true, include `pantsbuild.pants.testutil` to write tests for your plugin."
2✔
29

30

UNCOV
31
class PantsRequirementsVersionSpecField(StringField):
2✔
UNCOV
32
    alias = "version_spec"
2✔
UNCOV
33
    default = f"== {PANTS_SEMVER.public}"
2✔
UNCOV
34
    help = help_text(
2✔
35
        """
36
        The PEP 440 version specifier version of Pants to target.
37
        E.g. `== 2.15.*`, or `>= 2.16.0, < 2.17.0`
38
        """
39
    )
40

41

UNCOV
42
class PantsRequirementsTargetGenerator(TargetGenerator):
2✔
UNCOV
43
    alias = "pants_requirements"
2✔
UNCOV
44
    help = help_text(
2✔
45
        """
46
        Generate `python_requirement` targets for Pants itself to use with Pants plugins.
47

48
        This is useful when writing plugins so that you can build and test your
49
        plugin using Pants.
50

51
        The generated targets will have the correct version based on the exact `version` in your
52
        `pants.toml`, and they will work with dependency inference. They're pulled directly from
53
        our GitHub releases, using the relevant platform markers.
54

55
        (If this versioning scheme does not work for you, you can directly create
56
        `python_requirement` targets for `pantsbuild.pants` and `pantsbuild.pants.testutil`. We
57
        also invite you to share your ideas at
58
        https://github.com/pantsbuild/pants/issues/new/choose)
59
        """
60
    )
UNCOV
61
    generated_target_cls = PythonRequirementTarget
2✔
UNCOV
62
    core_fields = (
2✔
63
        *COMMON_TARGET_FIELDS,
64
        PantsRequirementsVersionSpecField,
65
        PantsRequirementsTestutilField,
66
        PythonRequirementFindLinksField,
67
    )
UNCOV
68
    copied_fields = COMMON_TARGET_FIELDS
2✔
UNCOV
69
    moved_fields = (PythonRequirementResolveField,)
2✔
70

71

UNCOV
72
class GenerateFromPantsRequirementsRequest(GenerateTargetsRequest):
2✔
UNCOV
73
    generate_from = PantsRequirementsTargetGenerator
2✔
74

75

UNCOV
76
@rule
2✔
UNCOV
77
async def generate_from_pants_requirements(
2✔
78
    request: GenerateFromPantsRequirementsRequest, union_membership: UnionMembership
79
) -> GeneratedTargets:
80
    generator = request.generator
×
81
    version_spec = generator[PantsRequirementsVersionSpecField].value
×
82

83
    def create_tgt(dist: str, module: str) -> PythonRequirementTarget:
×
84
        return PythonRequirementTarget(
×
85
            {
86
                PythonRequirementsField.alias: (f"{dist} {version_spec}",),
87
                PythonRequirementFindLinksField.alias: ("https://wheels.pantsbuild.org/simple",),
88
                PythonRequirementModulesField.alias: (module,),
89
                **request.template,
90
            },
91
            request.template_address.create_generated(dist),
92
            union_membership,
93
        )
94

95
    result = [create_tgt("pantsbuild.pants", "pants")]
×
96
    if generator[PantsRequirementsTestutilField].value:
×
97
        result.append(create_tgt("pantsbuild.pants.testutil", "pants.testutil"))
×
98
    return GeneratedTargets(generator, result)
×
99

100

UNCOV
101
def rules():
2✔
UNCOV
102
    return (
2✔
103
        *collect_rules(),
104
        UnionRule(GenerateTargetsRequest, GenerateFromPantsRequirementsRequest),
105
    )
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