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

pantsbuild / pants / 24145062409

08 Apr 2026 03:56PM UTC coverage: 52.369% (-40.5%) from 92.91%
24145062409

Pull #23233

github

web-flow
Merge 7a7652ebe into 9036734c9
Pull Request #23233: Introduce a LockfileFormat enum.

7 of 10 new or added lines in 3 files covered. (70.0%)

23048 existing lines in 605 files now uncovered.

31656 of 60448 relevant lines covered (52.37%)

0.52 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

UNCOV
4
from __future__ import annotations
×
5

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

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

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

20

UNCOV
21
class ClangFormat(PythonToolBase):
×
UNCOV
22
    options_scope = "clang-format"
×
UNCOV
23
    name = "ClangFormat"
×
UNCOV
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

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

UNCOV
35
    register_interpreter_constraints = True
×
36

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

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

UNCOV
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."""
UNCOV
45
        config_files = (
×
46
            ".clang-format",
47
            "_clang-format",
48
        )
UNCOV
49
        check_existence = [os.path.join(d, file) for file in config_files for d in ("", *dirs)]
×
UNCOV
50
        return ConfigFilesRequest(
×
51
            discovery=True,
52
            check_existence=check_existence,
53
        )
54

55

UNCOV
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