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

pantsbuild / pants / 19636484222

24 Nov 2025 01:45PM UTC coverage: 78.831% (-1.5%) from 80.283%
19636484222

Pull #22917

github

web-flow
Merge d61443516 into 612e19cd8
Pull Request #22917: Mostly revert "Temporarily disable macos cache"

74398 of 94376 relevant lines covered (78.83%)

2.9 hits per line

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

67.65
/src/python/pants/backend/tools/taplo/rules.py
1
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from typing import Any
1✔
5

6
from pants.backend.tools.taplo.subsystem import Taplo
1✔
7
from pants.core.goals.fmt import FmtFilesRequest, FmtResult, Partitions
1✔
8
from pants.core.goals.resolves import ExportableTool
1✔
9
from pants.core.util_rules.config_files import find_config_file
1✔
10
from pants.core.util_rules.external_tool import download_external_tool
1✔
11
from pants.engine.fs import MergeDigests
1✔
12
from pants.engine.intrinsics import merge_digests
1✔
13
from pants.engine.platform import Platform
1✔
14
from pants.engine.process import Process, execute_process_or_raise
1✔
15
from pants.engine.rules import collect_rules, concurrently, implicitly, rule
1✔
16
from pants.engine.unions import UnionRule
1✔
17
from pants.source.filespec import FilespecMatcher
1✔
18
from pants.util.logging import LogLevel
1✔
19
from pants.util.strutil import pluralize
1✔
20

21

22
class TaploFmtRequest(FmtFilesRequest):
1✔
23
    tool_subsystem = Taplo  # type: ignore[assignment]
1✔
24

25

26
@rule
1✔
27
async def partition_inputs(
1✔
28
    request: TaploFmtRequest.PartitionRequest, taplo: Taplo
29
) -> Partitions[Any]:
30
    if taplo.skip or not request.files:
×
31
        return Partitions()
×
32

33
    matched_filepaths = FilespecMatcher(
×
34
        includes=[
35
            (glob[2:] if glob.startswith(r"\\!") else glob)
36
            for glob in taplo.glob_pattern
37
            if not glob.startswith("!")
38
        ],
39
        excludes=[glob[1:] for glob in taplo.glob_pattern if glob.startswith("!")],
40
    ).matches(tuple(request.files))
41

42
    return Partitions.single_partition(sorted(matched_filepaths))
×
43

44

45
@rule(desc="Format with taplo", level=LogLevel.DEBUG)
1✔
46
async def taplo_fmt(request: TaploFmtRequest.Batch, taplo: Taplo, platform: Platform) -> FmtResult:
1✔
47
    download_taplo_get = download_external_tool(taplo.get_request(platform))
×
48
    config_files_get = find_config_file(taplo.config_request())
×
49
    downloaded_taplo, config_digest = await concurrently(download_taplo_get, config_files_get)
×
50
    input_digest = await merge_digests(
×
51
        MergeDigests(
52
            (request.snapshot.digest, downloaded_taplo.digest, config_digest.snapshot.digest)
53
        )
54
    )
55

56
    argv = (
×
57
        downloaded_taplo.exe,
58
        "fmt",
59
        *taplo.args,
60
        *request.files,
61
    )
62
    result = await execute_process_or_raise(
×
63
        **implicitly(
64
            Process(
65
                argv=argv,
66
                input_digest=input_digest,
67
                output_files=request.files,
68
                description=f"Run taplo on {pluralize(len(request.files), 'file')}.",
69
                level=LogLevel.DEBUG,
70
            )
71
        )
72
    )
73
    return await FmtResult.create(request, result)
×
74

75

76
def rules():
1✔
77
    return (
1✔
78
        *collect_rules(),
79
        *TaploFmtRequest.rules(),
80
        UnionRule(ExportableTool, Taplo),
81
    )
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