• 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

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).
UNCOV
3
from __future__ import annotations
×
4

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

UNCOV
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

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

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

26

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

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

UNCOV
35
    def to_json_dict(self):
×
UNCOV
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

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

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

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

60

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

65

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

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

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

87

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

UNCOV
94
    @classmethod
×
UNCOV
95
    def from_json_dict(cls, d: Any):
×
UNCOV
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

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

111

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

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

UNCOV
122
    def to_json_dict(self):
×
UNCOV
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

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

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

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

147

UNCOV
148
@dataclass(frozen=True)
×
UNCOV
149
class DependencySourcesItem:
×
UNCOV
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.
UNCOV
154
    sources: tuple[Uri, ...]
×
155

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

162

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

UNCOV
167
    def to_json_dict(self):
×
UNCOV
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

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

UNCOV
181
    @classmethod
×
UNCOV
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

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

192

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

198
    # Module version
UNCOV
199
    version: str
×
200

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

UNCOV
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

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

UNCOV
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

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

UNCOV
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