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

pantsbuild / pants / 18252174847

05 Oct 2025 01:36AM UTC coverage: 43.382% (-36.9%) from 80.261%
18252174847

push

github

web-flow
run tests on mac arm (#22717)

Just doing the minimal to pull forward the x86_64 pattern.

ref #20993

25776 of 59416 relevant lines covered (43.38%)

1.3 hits per line

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

0.0
/src/python/pants/bsp/spec/compile.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 typing import Any
×
7

8
from pants.bsp.spec.base import BuildTargetIdentifier
×
9

10
# -----------------------------------------------------------------------------------------------
11
# Compile Request
12
# See https://build-server-protocol.github.io/docs/specification.html#compile-request
13
# -----------------------------------------------------------------------------------------------
14

15

16
@dataclass(frozen=True)
×
17
class CompileParams:
×
18
    # A sequence of build targets to compile.
19
    targets: tuple[BuildTargetIdentifier, ...]
×
20

21
    # A unique identifier generated by the client to identify this request.
22
    # The server may include this id in triggered notifications or responses.
23
    origin_id: str | None = None
×
24

25
    # Optional arguments to the compilation process.
26
    arguments: tuple[str, ...] | None = ()
×
27

28
    @classmethod
×
29
    def from_json_dict(cls, d: dict[str, Any]) -> Any:
×
30
        return cls(
×
31
            targets=tuple(BuildTargetIdentifier.from_json_dict(x) for x in d["targets"]),
32
            origin_id=d.get("originId"),
33
            arguments=tuple(d["arguments"]) if "arguments" in d else None,
34
        )
35

36
    def to_json_dict(self) -> dict[str, Any]:
×
37
        result: dict[str, Any] = {"targets": [tgt.to_json_dict() for tgt in self.targets]}
×
38
        if self.origin_id is not None:
×
39
            result["originId"] = self.origin_id
×
40
        if self.arguments is not None:
×
41
            result["arguments"] = self.arguments
×
42
        return result
×
43

44

45
@dataclass(frozen=True)
×
46
class CompileResult:
×
47
    # An optional request id to know the origin of this report.
48
    origin_id: str | None
×
49

50
    # A status code for the execution.
51
    status_code: int
×
52

53
    # Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified.
54
    data_kind: str | None = None
×
55

56
    # A field containing language-specific information, like products
57
    # of compilation or compiler-specific metadata the client needs to know.
58
    data: Any | None = None
×
59

60
    @classmethod
×
61
    def from_json_dict(cls, d: dict[str, Any]) -> Any:
×
62
        return cls(
×
63
            origin_id=d.get("originId"),
64
            status_code=d["statusCode"],
65
            data_kind=d.get("dataKind"),
66
            data=d.get("data"),
67
        )
68

69
    def to_json_dict(self) -> dict[str, Any]:
×
70
        result: dict[str, Any] = {
×
71
            "statusCode": self.status_code,
72
        }
73
        if self.origin_id is not None:
×
74
            result["originId"] = self.origin_id
×
75
        if self.data_kind is not None:
×
76
            result["dataKind"] = self.data_kind
×
77
        if self.data is not None:
×
78
            result["data"] = self.data  # TODO: Enforce to_json_dict available
×
79
        return result
×
80

81

82
@dataclass(frozen=True)
×
83
class CompileTask:
×
84
    target: BuildTargetIdentifier
×
85

86
    @classmethod
×
87
    def from_json_dict(cls, d: dict[str, Any]) -> Any:
×
88
        return cls(target=BuildTargetIdentifier.from_json_dict(d["target"]))
×
89

90
    def to_json_dict(self) -> dict[str, Any]:
×
91
        return {"target": self.target.to_json_dict()}
×
92

93

94
@dataclass(frozen=True)
×
95
class CompileReport:
×
96
    # The build target that was compiled
97
    target: BuildTargetIdentifier
×
98

99
    # An optional request id to know the origin of this report.
100
    origin_id: str | None
×
101

102
    # The total number of reported errors compiling this target.
103
    errors: int
×
104

105
    # The total number of reported warnings compiling the target.
106
    warnings: int
×
107

108
    # The total number of milliseconds it took to compile the target.
109
    time: int | None = None
×
110

111
    # The compilation was a noOp compilation.
112
    no_op: bool | None = None
×
113

114
    @classmethod
×
115
    def from_json_dict(cls, d: dict[str, Any]) -> Any:
×
116
        return cls(
×
117
            target=BuildTargetIdentifier.from_json_dict(d["target"]),
118
            origin_id=d.get("originId"),
119
            errors=d["errors"],
120
            warnings=d["warnings"],
121
            time=d.get("time"),
122
            no_op=d.get("noOp"),
123
        )
124

125
    def to_json_dict(self) -> dict[str, Any]:
×
126
        result = {
×
127
            "target": self.target.to_json_dict(),
128
            "errors": self.errors,
129
            "warnings": self.warnings,
130
        }
131
        if self.origin_id is not None:
×
132
            result["originId"] = self.origin_id
×
133
        if self.time is not None:
×
134
            result["time"] = self.time
×
135
        if self.no_op is not None:
×
136
            result["noOp"] = self.no_op
×
137
        return result
×
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

© 2025 Coveralls, Inc