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

pantsbuild / pants / 24044100840

06 Apr 2026 06:11PM UTC coverage: 45.109% (-47.8%) from 92.908%
24044100840

Pull #23205

github

web-flow
Merge 4b5d6fed1 into 542ca048d
Pull Request #23205: Bump the gha-deps group across 1 directory with 5 updates

10790 of 23920 relevant lines covered (45.11%)

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

4
from __future__ import annotations
×
5

6
import os
×
7
from collections.abc import Iterable
×
8

9
from pants.backend.python.subsystems.python_tool_base import PythonToolBase
×
10
from pants.backend.python.target_types import ConsoleScript
×
11
from pants.core.goals.resolves import ExportableTool
×
12
from pants.core.util_rules.config_files import ConfigFilesRequest
×
13
from pants.engine.rules import Rule, collect_rules
×
14
from pants.engine.unions import UnionRule
×
15
from pants.option.option_types import ArgsListOption, SkipOption
×
16
from pants.util.strutil import help_text
×
17

18
# pants: infer-dep(clangformat.lock*)
19

20

21
class ClangFormat(PythonToolBase):
×
22
    options_scope = "clang-format"
×
23
    name = "ClangFormat"
×
24
    help_short = help_text(
×
25
        """
26
        The clang-format utility for formatting C/C++ (and others) code
27
        (https://clang.llvm.org/docs/ClangFormat.html). The clang-format binaries
28
        are retrieved from PyPi (https://pypi.org/project/clang-format/).
29
        """
30
    )
31

32
    default_main = ConsoleScript("clang-format")
×
33
    default_requirements = ["clang-format>=14.0.3,<16"]
×
34

35
    register_interpreter_constraints = True
×
36

37
    skip = SkipOption("fmt", "lint")
×
38
    args = ArgsListOption(example="--version")
×
39

40
    default_lockfile_resource = ("pants.backend.cc.lint.clangformat", "clangformat.lock")
×
41

42
    def config_request(self, dirs: Iterable[str]) -> ConfigFilesRequest:
×
43
        """clang-format will use the closest configuration file to the file currently being
44
        formatted, so add all of them."""
45
        config_files = (
×
46
            ".clang-format",
47
            "_clang-format",
48
        )
49
        check_existence = [os.path.join(d, file) for file in config_files for d in ("", *dirs)]
×
50
        return ConfigFilesRequest(
×
51
            discovery=True,
52
            check_existence=check_existence,
53
        )
54

55

56
def rules() -> Iterable[Rule | UnionRule]:
×
57
    return [
×
58
        *collect_rules(),
59
        UnionRule(ExportableTool, ClangFormat),
60
    ]
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