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

pantsbuild / pants / 25441711719

06 May 2026 02:31PM UTC coverage: 92.915%. Remained the same
25441711719

push

github

web-flow
use sha pin (with comment) format for generated actions (#23312)

Per the GitHub Action best practices we recently enabled at #23249, we
should pin each action to a SHA so that the reference is actually
immutable.

This will -- I hope -- knock out a large chunk of the 421 alerts we
currently get from zizmor. The next followup would then be upgrades and
harmonizing the generated and none-generated pins.

Notice: This idea was suggested by Claude while going over pinact output
and I was surprised to see that post processing the yaml wasn't too
gross.

92206 of 99237 relevant lines covered (92.91%)

4.04 hits per line

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

91.89
/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
2✔
4

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

9
from pants.bsp.spec.base import BSPData, BuildTarget, BuildTargetIdentifier, Uri
2✔
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)
2✔
18
class WorkspaceBuildTargetsParams:
2✔
19
    @classmethod
2✔
20
    def from_json_dict(cls, _d):
2✔
21
        return cls()
1✔
22

23
    def to_json_dict(self):
2✔
24
        return {}
1✔
25

26

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

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

35
    def to_json_dict(self):
2✔
36
        return {"targets": [tgt.to_json_dict() for tgt in self.targets]}
1✔
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)
2✔
46
class SourcesParams:
2✔
47
    targets: tuple[BuildTargetIdentifier, ...]
2✔
48

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

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

60

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

65

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

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

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

87

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

94
    @classmethod
2✔
95
    def from_json_dict(cls, d: Any):
2✔
96
        return cls(
1✔
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):
2✔
103
        result = {
1✔
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:
1✔
108
            result["roots"] = list(self.roots)
1✔
109
        return result
1✔
110

111

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

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

122
    def to_json_dict(self):
2✔
123
        return {"items": [item.to_json_dict() for item in self.items]}
1✔
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)
2✔
133
class DependencySourcesParams:
2✔
134
    targets: tuple[BuildTargetIdentifier, ...]
2✔
135

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

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

147

148
@dataclass(frozen=True)
2✔
149
class DependencySourcesItem:
2✔
150
    target: BuildTargetIdentifier
2✔
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, ...]
2✔
155

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

162

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

167
    def to_json_dict(self):
2✔
168
        return {"items": [item.to_json_dict() for item in self.items]}
1✔
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)
2✔
178
class DependencyModulesParams:
2✔
179
    targets: tuple[BuildTargetIdentifier, ...]
2✔
180

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

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

192

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

198
    # Module version
199
    version: str
2✔
200

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

205
    def to_json_dict(self) -> dict[str, Any]:
2✔
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)
2✔
217
class DependencyModulesItem:
2✔
218
    target: BuildTargetIdentifier
2✔
219
    modules: tuple[DependencyModule, ...]
2✔
220

221
    def to_json_dict(self) -> dict[str, Any]:
2✔
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)
2✔
229
class DependencyModulesResult:
2✔
230
    items: tuple[DependencyModulesItem, ...]
2✔
231

232
    def to_json_dict(self):
2✔
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