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

pantsbuild / pants / 20632486505

01 Jan 2026 04:21AM UTC coverage: 43.231% (-37.1%) from 80.281%
20632486505

Pull #22962

github

web-flow
Merge 08d5c63b0 into f52ab6675
Pull Request #22962: Bump the gha-deps group across 1 directory with 6 updates

26122 of 60424 relevant lines covered (43.23%)

0.86 hits per line

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

0.0
/src/python/pants/bsp/spec/targets.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3
from __future__ import annotations
×
4

5
from dataclasses import dataclass
×
6
from enum import IntEnum
×
7
from typing import Any
×
8

9
from pants.bsp.spec.base import BSPData, BuildTarget, BuildTargetIdentifier, Uri
×
10

11
# -----------------------------------------------------------------------------------------------
12
# Workspace Build Targets Request
13
# See https://build-server-protocol.github.io/docs/specification.html#workspace-build-targets-request
14
# -----------------------------------------------------------------------------------------------
15

16

17
@dataclass(frozen=True)
×
18
class WorkspaceBuildTargetsParams:
×
19
    @classmethod
×
20
    def from_json_dict(cls, _d):
×
21
        return cls()
×
22

23
    def to_json_dict(self):
×
24
        return {}
×
25

26

27
@dataclass(frozen=True)
×
28
class WorkspaceBuildTargetsResult:
×
29
    targets: tuple[BuildTarget, ...]
×
30

31
    @classmethod
×
32
    def from_json_dict(cls, d):
×
33
        return cls(targets=tuple(BuildTarget.from_json_dict(tgt) for tgt in d["targets"]))
×
34

35
    def to_json_dict(self):
×
36
        return {"targets": [tgt.to_json_dict() for tgt in self.targets]}
×
37

38

39
# -----------------------------------------------------------------------------------------------
40
# Build Target Sources Request
41
# See https://build-server-protocol.github.io/docs/specification.html#build-target-sources-request
42
# -----------------------------------------------------------------------------------------------
43

44

45
@dataclass(frozen=True)
×
46
class SourcesParams:
×
47
    targets: tuple[BuildTargetIdentifier, ...]
×
48

49
    @classmethod
×
50
    def from_json_dict(cls, d):
×
51
        return cls(
×
52
            targets=tuple(BuildTargetIdentifier.from_json_dict(x) for x in d["targets"]),
53
        )
54

55
    def to_json_dict(self):
×
56
        return {
×
57
            "targets": [tgt.to_json_dict() for tgt in self.targets],
58
        }
59

60

61
class SourceItemKind(IntEnum):
×
62
    FILE = 1
×
63
    DIRECTORY = 2
×
64

65

66
@dataclass(frozen=True)
×
67
class SourceItem:
×
68
    uri: Uri
×
69
    kind: SourceItemKind
×
70
    generated: bool = False
×
71

72
    @classmethod
×
73
    def from_json_dict(cls, d: Any):
×
74
        return cls(
×
75
            uri=d["uri"],
76
            kind=SourceItemKind(d["kind"]),
77
            generated=d["generated"],
78
        )
79

80
    def to_json_dict(self):
×
81
        return {
×
82
            "uri": self.uri,
83
            "kind": self.kind.value,
84
            "generated": self.generated,
85
        }
86

87

88
@dataclass(frozen=True)
×
89
class SourcesItem:
×
90
    target: BuildTargetIdentifier
×
91
    sources: tuple[SourceItem, ...]
×
92
    roots: tuple[Uri, ...] | None
×
93

94
    @classmethod
×
95
    def from_json_dict(cls, d: Any):
×
96
        return cls(
×
97
            target=BuildTargetIdentifier.from_json_dict(d["target"]),
98
            sources=tuple(SourceItem.from_json_dict(i) for i in d["sources"]),
99
            roots=tuple(d.get("sources", ())),
100
        )
101

102
    def to_json_dict(self):
×
103
        result = {
×
104
            "target": self.target.to_json_dict(),
105
            "sources": [src.to_json_dict() for src in self.sources],
106
        }
107
        if self.roots is not None:
×
108
            result["roots"] = list(self.roots)
×
109
        return result
×
110

111

112
@dataclass(frozen=True)
×
113
class SourcesResult:
×
114
    items: tuple[SourcesItem, ...]
×
115

116
    @classmethod
×
117
    def from_json_dict(cls, d: Any):
×
118
        return cls(
×
119
            items=tuple(SourcesItem.from_json_dict(i) for i in d["items"]),
120
        )
121

122
    def to_json_dict(self):
×
123
        return {"items": [item.to_json_dict() for item in self.items]}
×
124

125

126
# -----------------------------------------------------------------------------------------------
127
# Dependency Sources Request
128
# See https://build-server-protocol.github.io/docs/specification.html#dependency-sources-request
129
# -----------------------------------------------------------------------------------------------
130

131

132
@dataclass(frozen=True)
×
133
class DependencySourcesParams:
×
134
    targets: tuple[BuildTargetIdentifier, ...]
×
135

136
    @classmethod
×
137
    def from_json_dict(cls, d):
×
138
        return cls(
×
139
            targets=tuple(BuildTargetIdentifier.from_json_dict(x) for x in d["targets"]),
140
        )
141

142
    def to_json_dict(self):
×
143
        return {
×
144
            "targets": [tgt.to_json_dict() for tgt in self.targets],
145
        }
146

147

148
@dataclass(frozen=True)
×
149
class DependencySourcesItem:
×
150
    target: BuildTargetIdentifier
×
151
    # List of resources containing source files of the
152
    # target's dependencies.
153
    # Can be source files, jar files, zip files, or directories.
154
    sources: tuple[Uri, ...]
×
155

156
    def to_json_dict(self) -> dict[str, Any]:
×
157
        return {
×
158
            "target": self.target.to_json_dict(),
159
            "sources": self.sources,
160
        }
161

162

163
@dataclass(frozen=True)
×
164
class DependencySourcesResult:
×
165
    items: tuple[DependencySourcesItem, ...]
×
166

167
    def to_json_dict(self):
×
168
        return {"items": [item.to_json_dict() for item in self.items]}
×
169

170

171
# -----------------------------------------------------------------------------------------------
172
# Dependency Modules Request
173
# See https://build-server-protocol.github.io/docs/specification.html#dependency-modules-request
174
# -----------------------------------------------------------------------------------------------
175

176

177
@dataclass(frozen=True)
×
178
class DependencyModulesParams:
×
179
    targets: tuple[BuildTargetIdentifier, ...]
×
180

181
    @classmethod
×
182
    def from_json_dict(cls, d):
×
183
        return cls(
×
184
            targets=tuple(BuildTargetIdentifier.from_json_dict(x) for x in d["targets"]),
185
        )
186

187
    def to_json_dict(self):
×
188
        return {
×
189
            "targets": [tgt.to_json_dict() for tgt in self.targets],
190
        }
191

192

193
@dataclass(frozen=True)
×
194
class DependencyModule:
×
195
    # Module name
196
    name: str
×
197

198
    # Module version
199
    version: str
×
200

201
    # Language-specific metadata about this module.
202
    # See MavenDependencyModule as an example.
203
    data: BSPData | None
×
204

205
    def to_json_dict(self) -> dict[str, Any]:
×
206
        result: dict[str, Any] = {
×
207
            "name": self.name,
208
            "version": self.version,
209
        }
210
        if self.data is not None:
×
211
            result["dataKind"] = self.data.DATA_KIND
×
212
            result["data"] = self.data.to_json_dict()
×
213
        return result
×
214

215

216
@dataclass(frozen=True)
×
217
class DependencyModulesItem:
×
218
    target: BuildTargetIdentifier
×
219
    modules: tuple[DependencyModule, ...]
×
220

221
    def to_json_dict(self) -> dict[str, Any]:
×
222
        return {
×
223
            "target": self.target.to_json_dict(),
224
            "modules": [m.to_json_dict() for m in self.modules],
225
        }
226

227

228
@dataclass(frozen=True)
×
229
class DependencyModulesResult:
×
230
    items: tuple[DependencyModulesItem, ...]
×
231

232
    def to_json_dict(self):
×
233
        return {"items": [item.to_json_dict() for item in self.items]}
×
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