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

UNCOV
4
from __future__ import annotations
×
5

UNCOV
6
import logging
×
UNCOV
7
from collections.abc import Iterable
×
UNCOV
8
from dataclasses import dataclass
×
9

UNCOV
10
from pants.backend.cc.lint.clangformat.subsystem import ClangFormat
×
UNCOV
11
from pants.backend.cc.target_types import CCSourceField
×
UNCOV
12
from pants.backend.python.util_rules.pex import PexProcess, create_pex
×
UNCOV
13
from pants.core.goals.fmt import FmtResult, FmtTargetsRequest
×
UNCOV
14
from pants.core.util_rules.config_files import find_config_file
×
UNCOV
15
from pants.core.util_rules.partitions import PartitionerType
×
UNCOV
16
from pants.engine.fs import MergeDigests
×
UNCOV
17
from pants.engine.intrinsics import merge_digests
×
UNCOV
18
from pants.engine.process import fallible_to_exec_result_or_raise
×
UNCOV
19
from pants.engine.rules import Rule, collect_rules, concurrently, implicitly, rule
×
UNCOV
20
from pants.engine.target import FieldSet
×
UNCOV
21
from pants.engine.unions import UnionRule
×
UNCOV
22
from pants.util.logging import LogLevel
×
UNCOV
23
from pants.util.strutil import pluralize
×
24

UNCOV
25
logger = logging.getLogger(__name__)
×
26

27

UNCOV
28
@dataclass(frozen=True)
×
UNCOV
29
class ClangFormatFmtFieldSet(FieldSet):
×
UNCOV
30
    required_fields = (CCSourceField,)
×
31

UNCOV
32
    sources: CCSourceField
×
33

34

UNCOV
35
class ClangFormatRequest(FmtTargetsRequest):
×
UNCOV
36
    field_set_type = ClangFormatFmtFieldSet
×
UNCOV
37
    tool_subsystem = ClangFormat  # type: ignore[assignment]
×
UNCOV
38
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
×
39

40

UNCOV
41
@rule(level=LogLevel.DEBUG)
×
UNCOV
42
async def clangformat_fmt(request: ClangFormatRequest.Batch, clangformat: ClangFormat) -> FmtResult:
×
43
    clangformat_pex, config_files = await concurrently(
×
44
        create_pex(clangformat.to_pex_request()),
45
        find_config_file(clangformat.config_request(request.snapshot.dirs)),
46
    )
47

48
    # Merge source files, config files, and clang-format pex process
49
    input_digest = await merge_digests(
×
50
        MergeDigests(
51
            [request.snapshot.digest, config_files.snapshot.digest, clangformat_pex.digest]
52
        )
53
    )
54

55
    argv = (
×
56
        "--style=file",  # Look for .clang-format files
57
        "--fallback-style=webkit",  # Use WebKit if there is no config file
58
        "-i",  # In-place edits
59
        "--Werror",  # Formatting warnings as errors
60
        *clangformat.args,  # User-added arguments
61
        *request.files,
62
    )
63
    result = await fallible_to_exec_result_or_raise(
×
64
        **implicitly(
65
            PexProcess(
66
                clangformat_pex,
67
                argv=argv,
68
                input_digest=input_digest,
69
                output_files=request.files,
70
                description=f"Run clang-format on {pluralize(len(request.files), 'file')}.",
71
                level=LogLevel.DEBUG,
72
            )
73
        ),
74
    )
75

76
    return await FmtResult.create(request, result)
×
77

78

UNCOV
79
def rules() -> Iterable[Rule | UnionRule]:
×
UNCOV
80
    return (
×
81
        *collect_rules(),
82
        *ClangFormatRequest.rules(),
83
    )
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