• 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/backend/shell/lint/shfmt/rules.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from dataclasses import dataclass
×
5

UNCOV
6
from pants.backend.shell.lint.shfmt.skip_field import SkipShfmtField
×
UNCOV
7
from pants.backend.shell.lint.shfmt.subsystem import Shfmt
×
UNCOV
8
from pants.backend.shell.target_types import ShellSourceField
×
UNCOV
9
from pants.core.goals.fmt import FmtResult, FmtTargetsRequest
×
UNCOV
10
from pants.core.goals.resolves import ExportableTool
×
UNCOV
11
from pants.core.util_rules.config_files import find_config_file
×
UNCOV
12
from pants.core.util_rules.external_tool import download_external_tool
×
UNCOV
13
from pants.core.util_rules.partitions import PartitionerType
×
UNCOV
14
from pants.engine.fs import MergeDigests
×
UNCOV
15
from pants.engine.intrinsics import merge_digests
×
UNCOV
16
from pants.engine.platform import Platform
×
UNCOV
17
from pants.engine.process import Process, execute_process_or_raise
×
UNCOV
18
from pants.engine.rules import collect_rules, concurrently, implicitly, rule
×
UNCOV
19
from pants.engine.target import FieldSet, Target
×
UNCOV
20
from pants.engine.unions import UnionRule
×
UNCOV
21
from pants.util.logging import LogLevel
×
UNCOV
22
from pants.util.strutil import pluralize
×
23

24

UNCOV
25
@dataclass(frozen=True)
×
UNCOV
26
class ShfmtFieldSet(FieldSet):
×
UNCOV
27
    required_fields = (ShellSourceField,)
×
28

29
    sources: ShellSourceField
30

UNCOV
31
    @classmethod
×
UNCOV
32
    def opt_out(cls, tgt: Target) -> bool:
×
33
        return tgt.get(SkipShfmtField).value
×
34

35

UNCOV
36
class ShfmtRequest(FmtTargetsRequest):
×
UNCOV
37
    field_set_type = ShfmtFieldSet
×
UNCOV
38
    tool_subsystem = Shfmt  # type: ignore[assignment]
×
UNCOV
39
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
×
40

41

UNCOV
42
@rule(desc="Format with shfmt", level=LogLevel.DEBUG)
×
UNCOV
43
async def shfmt_fmt(request: ShfmtRequest.Batch, shfmt: Shfmt, platform: Platform) -> FmtResult:
×
44
    download_shfmt_get = download_external_tool(shfmt.get_request(platform))
×
45
    config_files_get = find_config_file(shfmt.config_request(request.snapshot.dirs))
×
46
    downloaded_shfmt, config_files = await concurrently(download_shfmt_get, config_files_get)
×
47
    input_digest = await merge_digests(
×
48
        MergeDigests(
49
            (request.snapshot.digest, downloaded_shfmt.digest, config_files.snapshot.digest)
50
        )
51
    )
52

53
    result = await execute_process_or_raise(
×
54
        **implicitly(
55
            Process(
56
                argv=(
57
                    downloaded_shfmt.exe,
58
                    "-l",
59
                    "-w",
60
                    *shfmt.args,
61
                    *request.files,
62
                ),
63
                input_digest=input_digest,
64
                output_files=request.files,
65
                description=f"Run shfmt on {pluralize(len(request.files), 'file')}.",
66
                level=LogLevel.DEBUG,
67
            )
68
        )
69
    )
70
    return await FmtResult.create(request, result)
×
71

72

UNCOV
73
def rules():
×
UNCOV
74
    return [
×
75
        *collect_rules(),
76
        *ShfmtRequest.rules(),
77
        UnionRule(ExportableTool, Shfmt),
78
    ]
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