• 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

97.1
/src/python/pants/backend/openapi/target_types.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from __future__ import annotations
6✔
5

UNCOV
6
from pants.engine.rules import collect_rules, rule
6✔
UNCOV
7
from pants.engine.target import (
6✔
8
    COMMON_TARGET_FIELDS,
9
    AllTargets,
10
    Dependencies,
11
    MultipleSourcesField,
12
    OptionalSingleSourceField,
13
    SingleSourceField,
14
    StringField,
15
    Target,
16
    TargetFilesGenerator,
17
    Targets,
18
    generate_multiple_sources_field_help_message,
19
)
UNCOV
20
from pants.util.logging import LogLevel
6✔
UNCOV
21
from pants.util.strutil import help_text
6✔
22

UNCOV
23
OPENAPI_FILE_EXTENSIONS = (".json", ".yaml", ".yml")
6✔
24

25

UNCOV
26
class OpenApiField(SingleSourceField):
6✔
UNCOV
27
    expected_file_extensions = OPENAPI_FILE_EXTENSIONS
6✔
28

29

UNCOV
30
class OpenApiGeneratorField(MultipleSourcesField):
6✔
UNCOV
31
    expected_file_extensions = OPENAPI_FILE_EXTENSIONS
6✔
32

33

34
# -----------------------------------------------------------------------------------------------
35
# `openapi_document` and `openapi_documents` targets
36
# -----------------------------------------------------------------------------------------------
37

38

UNCOV
39
class OpenApiDocumentField(OpenApiField):
6✔
UNCOV
40
    pass
6✔
41

42

UNCOV
43
class OpenApiDocumentDependenciesField(Dependencies):
6✔
UNCOV
44
    pass
6✔
45

46

UNCOV
47
class OpenApiDocumentTarget(Target):
6✔
UNCOV
48
    alias = "openapi_document"
6✔
UNCOV
49
    core_fields = (
6✔
50
        *COMMON_TARGET_FIELDS,
51
        OpenApiDocumentDependenciesField,
52
        OpenApiDocumentField,
53
    )
UNCOV
54
    help = "A single OpenAPI document file."
6✔
55

56

UNCOV
57
class OpenApiDocumentGeneratorField(OpenApiGeneratorField):
6✔
UNCOV
58
    default = tuple(f"openapi{ext}" for ext in OPENAPI_FILE_EXTENSIONS)
6✔
UNCOV
59
    help = generate_multiple_sources_field_help_message("Example: `sources=['openapi.json']`")
6✔
60

61

UNCOV
62
class OpenApiDocumentGeneratorTarget(TargetFilesGenerator):
6✔
UNCOV
63
    alias = "openapi_documents"
6✔
UNCOV
64
    core_fields = (
6✔
65
        *COMMON_TARGET_FIELDS,
66
        OpenApiDocumentGeneratorField,
67
    )
UNCOV
68
    generated_target_cls = OpenApiDocumentTarget
6✔
UNCOV
69
    copied_fields = COMMON_TARGET_FIELDS
6✔
UNCOV
70
    moved_fields = (OpenApiDocumentDependenciesField,)
6✔
UNCOV
71
    help = (
6✔
72
        f"Generate an `{OpenApiDocumentTarget.alias}` target for each file in the `sources` field."
73
    )
74

75

UNCOV
76
class AllOpenApiDocumentTargets(Targets):
6✔
UNCOV
77
    pass
6✔
78

79

UNCOV
80
@rule(desc="Find all OpenAPI Document targets in project", level=LogLevel.DEBUG)
6✔
UNCOV
81
async def find_all_openapi_document_targets(all_targets: AllTargets) -> AllOpenApiDocumentTargets:
6✔
82
    return AllOpenApiDocumentTargets(
×
83
        tgt for tgt in all_targets if tgt.has_field(OpenApiDocumentField)
84
    )
85

86

87
# -----------------------------------------------------------------------------------------------
88
# `openapi_source` and `openapi_sources` targets
89
# -----------------------------------------------------------------------------------------------
90

91

UNCOV
92
class OpenApiSourceField(OpenApiField):
6✔
UNCOV
93
    pass
6✔
94

95

UNCOV
96
class OpenApiSourceDependenciesField(Dependencies):
6✔
UNCOV
97
    pass
6✔
98

99

UNCOV
100
class OpenApiSourceTarget(Target):
6✔
UNCOV
101
    alias = "openapi_source"
6✔
UNCOV
102
    core_fields = (
6✔
103
        *COMMON_TARGET_FIELDS,
104
        OpenApiSourceDependenciesField,
105
        OpenApiSourceField,
106
    )
UNCOV
107
    help = "A single OpenAPI source file."
6✔
108

109

UNCOV
110
class OpenApiSourceGeneratorField(OpenApiGeneratorField):
6✔
UNCOV
111
    default = tuple(f"*{ext}" for ext in OPENAPI_FILE_EXTENSIONS)
6✔
UNCOV
112
    help = generate_multiple_sources_field_help_message("Example: `sources=['*.json']`")
6✔
113

114

UNCOV
115
class OpenApiSourceGeneratorTarget(TargetFilesGenerator):
6✔
UNCOV
116
    alias = "openapi_sources"
6✔
UNCOV
117
    core_fields = (
6✔
118
        *COMMON_TARGET_FIELDS,
119
        OpenApiSourceGeneratorField,
120
    )
UNCOV
121
    generated_target_cls = OpenApiSourceTarget
6✔
UNCOV
122
    copied_fields = COMMON_TARGET_FIELDS
6✔
UNCOV
123
    moved_fields = (OpenApiSourceDependenciesField,)
6✔
UNCOV
124
    help = f"Generate an `{OpenApiSourceTarget.alias}` target for each file in the `sources` field."
6✔
125

126

UNCOV
127
class AllOpenApiSourceTargets(Targets):
6✔
UNCOV
128
    pass
6✔
129

130

UNCOV
131
@rule(desc="Find all OpenAPI source targets in project", level=LogLevel.DEBUG)
6✔
UNCOV
132
async def find_all_openapi_source_targets(all_targets: AllTargets) -> AllOpenApiSourceTargets:
6✔
133
    return AllOpenApiSourceTargets(tgt for tgt in all_targets if tgt.has_field(OpenApiSourceField))
×
134

135

136
# -----------------------------------------------------------------------------------------------
137
# `openapi_bundle` target
138
# -----------------------------------------------------------------------------------------------
139

140

UNCOV
141
class OpenApiBundleSourceRootField(StringField):
6✔
UNCOV
142
    alias = "bundle_source_root"
6✔
UNCOV
143
    help = help_text(
6✔
144
        f"""
145
        The source root to bundle OpenAPI documents under.
146

147
        If unspecified, the source root the `{OpenApiDocumentGeneratorTarget.alias}` is under will be used.
148
        """
149
    )
150

151

UNCOV
152
class OpenApiBundleDependenciesField(Dependencies):
6✔
UNCOV
153
    pass
6✔
154

155

UNCOV
156
class OpenApiBundleDummySourceField(OptionalSingleSourceField):
6✔
UNCOV
157
    alias = "_source"
6✔
158

159

UNCOV
160
class OpenApiBundleTarget(Target):
6✔
UNCOV
161
    alias = "openapi_bundle"
6✔
UNCOV
162
    core_fields = (
6✔
163
        *COMMON_TARGET_FIELDS,
164
        OpenApiBundleDummySourceField,
165
        OpenApiBundleDependenciesField,
166
        OpenApiBundleSourceRootField,
167
    )
UNCOV
168
    help = help_text("An OpenAPI document bundled as a single source.")
6✔
169

170

UNCOV
171
def rules():
6✔
UNCOV
172
    return collect_rules()
4✔
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