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

pantsbuild / pants / 24638277381

19 Apr 2026 08:21PM UTC coverage: 52.377% (-40.5%) from 92.924%
24638277381

Pull #23274

github

web-flow
Merge 662e70df2 into 0283af69e
Pull Request #23274: rust: upgrade to v1.95.0

31658 of 60443 relevant lines covered (52.38%)

1.05 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